GAN_MNIST_torch module

class GAN_MNIST_torch.Discriminator_MNIST[source]

Bases: Module

Unconditional Discriminator model for MNIST dataset.

forward(x)[source]

Classifies the input image as real or fake.

Input:

x (Tensor): Input MNIST image of shape (BATCH, 1, 28, 28).

Output:

Tensor: Discriminator output scalar for each image in the batch.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class GAN_MNIST_torch.Discriminator_MNIST_cond[source]

Bases: Module

Conditional Discriminator model for MNIST dataset.

forward(x, z)[source]

Classifies the input image and label as real or fake.

Input:

x (Tensor): Input MNIST image of shape (BATCH, 1, 28, 28). z (Tensor): One-hot encoded label tensor of shape (BATCH, 10).

Output:

Tensor: Discriminator output scalar for each image in the batch.

forward(x, z)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class GAN_MNIST_torch.Generator_MNIST(latent_dim=118)[source]

Bases: Module

Unconditional Generator model for MNIST dataset.

Parameters:

latent_dim (int) – Dimension of the latent input vector. Default is 118.

forward(BATCH=16)[source]

Generates an image based on a random noise vector.

Input:

BATCH (int): Batch size for random latent vector generation. Default is 16.

Output:

Tensor: Generated image of shape (BATCH, 1, 28, 28).

forward(BATCH=16)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class GAN_MNIST_torch.Generator_MNIST_cond(latent_dim=118)[source]

Bases: Module

Conditional Generator model for MNIST dataset.

Parameters:

latent_dim (int) – Dimension of the latent input vector. Default is 118.

forward(label, BATCH=16)[source]

Generates an image conditioned on the input label and a random noise vector.

Input:

label (Tensor): One-hot encoded label tensor of shape (BATCH, 10). BATCH (int): Batch size for random latent vector generation. Default is 16.

Output:

Tensor: Generated image of shape (BATCH, 1, 28, 28).

forward(label, BATCH=16)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.