model_torch module
- class model_torch.BoundedActivation(M=100.0)[source]
Bases:
ModuleBounded Activation Layer that applies a bounded activation function using tanh.
- bounded_activation(x)
Apply the bounded activation to the input tensor.
- class model_torch.Discriminator(input_dim, batch_size, spec_norm, bounded, layers_list, device='cpu')[source]
Bases:
ModuleDiscriminator Class that initializes and processes the discriminator network.
- Parameters:
input_dim (int) – Dimension of the input features.
batch_size (int) – Batch size for processing.
spec_norm (bool) – Whether to apply spectral normalization to the layers.
bounded (bool) – Whether to apply bounded activation on the final output.
layers_list (list) – List of integers specifying the number of units for each hidden layer.
device (str) – Device to run the model on (‘cpu’ or ‘cuda’).
- Returns:
Output after processing through the discriminator network.
- Return type:
torch.Tensor
- class model_torch.Discriminator_MNIST[source]
Bases:
ModuleDiscriminator Class for MNIST that processes the input and classifies real vs fake images.
- Returns:
Output after processing the input image through the discriminator network.
- Return type:
torch.Tensor
- class model_torch.Generator(X_dim, Z_dim, batch_size, spec_norm, layers_list, device='cpu')[source]
Bases:
ModuleGenerator Class that initializes and processes the generator network.
- Parameters:
X_dim (int) – Dimension of the output generated by the generator.
Z_dim (int) – Dimension of the input latent space.
batch_size (int) – Batch size for processing.
spec_norm (bool) – Whether to apply spectral normalization to the layers.
layers_list (list) – List of integers specifying the number of units for each hidden layer.
device (str) – Device to run the model on (‘cpu’ or ‘cuda’).
- Returns:
Generated output after processing the latent input.
- Return type:
torch.Tensor