model_tf module

class model_tf.Discriminator(*args, **kwargs)[source]

Bases: Model

Discriminator class responsible for initializing and processing the discriminator network.

Parameters:
  • input_dim (int) – Dimension of the input features.

  • 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.

call(inputs)[source]

Forward pass through the network.

bounded_activation(x)[source]

Activation function to apply bounded output using tanh.

Returns:

Output after processing through the discriminator network.

Return type:

tf.Tensor

bounded_activation()[source]

Apply a bounded activation using the tanh function, constraining the output within [-M, M].

Parameters:

x (tf.Tensor) – Input data.

Returns:

Output after applying bounded activation.

Return type:

tf.Tensor

call(inputs)[source]

Forward pass through the discriminator.

Parameters:

inputs (tf.Tensor) – Input data to the network.

Returns:

Discriminator’s prediction after processing the inputs.

Return type:

tf.Tensor

class model_tf.DiscriminatorMNIST(*args, **kwargs)[source]

Bases: Model

Discriminator class for the MNIST dataset, responsible for classifying real vs fake images.

call(x)[source]

Forward pass through the network.

Returns:

Output after processing the input image through the discriminator network.

Return type:

tf.Tensor

call(x)[source]

Forward pass through the MNIST discriminator.

Parameters:

x (tf.Tensor) – Input image data reshaped to (batch_size, 784).

Returns:

Output after processing through dense and normalization layers.

Return type:

tf.Tensor

class model_tf.Generator(*args, **kwargs)[source]

Bases: Model

Generator class responsible for initializing and processing the generator network.

Parameters:
  • X_dim (int) – Dimension of the output generated by the generator.

  • Z_dim (int) – Dimension of the input latent space.

  • 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.

call(inputs)[source]

Forward pass through the network.

Returns:

Generated output after processing the latent input.

Return type:

tf.Tensor

call(inputs)[source]

Forward pass through the generator.

Parameters:

inputs (tf.Tensor) – Input latent vector.

Returns:

Generated output.

Return type:

tf.Tensor