mmagic.models.editors.wgan_gp.wgan_generator
¶
Module Contents¶
Classes¶
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
Adopt convolution architecture specified in appendix A.2;
Use batchnorm in the generator except for the final output layer;
Use ReLU in the generator except for the final output layer;
Use Tanh in the last layer;
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.
- 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, theNone
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 withfake_img
. Defaults to False.
- Returns
- If not
return_noise
, only the output image will be returned. Otherwise, a dict contains
fake_img
andnoise_batch
will be returned.
- If not
- Return type
torch.Tensor | dict