Shortcuts

mmagic.models.editors.wgan_gp.wgan_generator

Module Contents

Classes

WGANGPGenerator

Generator for WGANGP.

class mmagic.models.editors.wgan_gp.wgan_generator.WGANGPGenerator(noise_size, out_scale, conv_module_cfg=None, upsample_cfg=None, init_cfg=None)[source]

Bases: mmengine.model.BaseModule

Generator for WGANGP.

Implementation Details for WGANGP generator the same as training configuration (a) described in PGGAN paper: PROGRESSIVE GROWING OF GANS FOR IMPROVED QUALITY, STABILITY, AND VARIATION https://research.nvidia.com/sites/default/files/pubs/2017-10_Progressive-Growing-of/karras2018iclr-paper.pdf # noqa

  1. Adopt convolution architecture specified in appendix A.2;

  2. Use batchnorm in the generator except for the final output layer;

  3. Use ReLU in the generator except for the final output layer;

  4. Use Tanh in the last layer;

  5. Initialize all weights using He’s initializer.

Parameters
  • noise_size (int) – Size of the input noise vector.

  • out_scale (int) – Output scale for the generated image.

  • conv_module_cfg (dict, optional) – Config for the convolution module used in this generator. Defaults to None.

  • upsample_cfg (dict, optional) – Config for the upsampling operation. Defaults to None.

  • init_cfg (dict, optional) – Initialization config dict.

_default_channels_per_scale[source]
_default_conv_module_cfg[source]
_default_upsample_cfg[source]
forward(noise, num_batches=0, return_noise=False)[source]

Forward function.

Parameters
  • noise (torch.Tensor | callable | None) – You can directly give a batch of noise through a torch.Tensor or offer a callable function to sample a batch of noise data. Otherwise, the None indicates to use the default noise sampler.

  • num_batches (int, optional) – The number of batch size. Defaults to 0.

  • return_noise (bool, optional) – If True, noise_batch will be returned in a dict with fake_img. Defaults to False.

Returns

If not return_noise, only the output image

will be returned. Otherwise, a dict contains fake_img and noise_batch will be returned.

Return type

torch.Tensor | dict

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.