Shortcuts

mmagic.models.editors.dcgan.dcgan_discriminator

Module Contents

Classes

DCGANDiscriminator

Discriminator for DCGAN.

class mmagic.models.editors.dcgan.dcgan_discriminator.DCGANDiscriminator(input_scale, output_scale, out_channels, in_channels=3, base_channels=128, default_norm_cfg=dict(type='BN'), default_act_cfg=dict(type='LeakyReLU'), out_act_cfg=None, init_cfg=None)[source]

Bases: mmengine.model.BaseModule

Discriminator for DCGAN.

Implementation Details for DCGAN architecture:

  1. Adopt convolution in the discriminator;

  2. Use batchnorm in the discriminator except for the input and final output layer;

  3. Use LeakyReLU in the discriminator in addition to the output layer.

Parameters
  • input_scale (int) – The scale of the input image.

  • output_scale (int) – The final scale of the convolutional feature.

  • out_channels (int) – The channel number of the final output layer.

  • in_channels (int, optional) – The channel number of the input image. Defaults to 3.

  • base_channels (int, optional) – The basic channel number of the generator. The other layers contains channels based on this number. Defaults to 128.

  • default_norm_cfg (dict, optional) – Norm config for all of layers except for the final output layer. Defaults to dict(type='BN').

  • default_act_cfg (dict, optional) – Activation config for all of layers except for the final output layer. Defaults to dict(type='ReLU').

  • out_act_cfg (dict, optional) – Activation config for the final output layer. Defaults to dict(type='Tanh').

  • pretrained (str, optional) – Path for the pretrained model. Default to None.

  • init_cfg (dict, optional) – Initialization config dict. Default: None.

forward(x)[source]

Forward function.

Parameters

x (torch.Tensor) – Fake or real image tensor.

Returns

Prediction for the reality of the input image.

Return type

torch.Tensor

init_weights()[source]

Init weights for models.

We just use the initialization method proposed in the original paper.

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.