DCGANDiscriminator#

class deeplay.models.discriminators.dcgan.DCGANDiscriminator(*args, **kwargs)#

Bases: ConvolutionalEncoder2d

Deep Convolutional Generative Adversarial Network (DCGAN) discriminator.

Parameters#

input_channels: int

Number of input channels

features_dim: int

Dimension of the features. The number of features in the four ConvBlocks of the Discriminator can be controlled by this parameter. Convolutional layers = [features_dim, features_dim*2, features_dim*4, features_dim*8].

class_conditioned_model: bool

Whether the model is class-conditional

embedding_dim: int

Dimension of the label embedding

num_classes: int

Number of classes

Shorthands#

  • input: .blocks[0]

  • hidden: .blocks[:-1]

  • output: .blocks[-1]

  • layer: .blocks.layer

  • activation: .blocks.activation

Constraints#

  • input shape: (batch_size, ch_in, 64, 64)

  • output shape: (batch_size, 1, 1, 1)

Examples#

>>> discriminator = DCGAN_Discriminator(input_channels=1, class_conditioned_model=False)
>>> discriminator.build()
>>> batch_size = 16
>>> input = torch.randn(batch_size, 1, 64, 64)
>>> output = discriminator(input)

Return Values#

The forward method returns the processed tensor.

Methods Summary

forward(x[, y])

Define the computation performed at every call.

Methods Documentation

forward(x, y=None)#

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.