Shortcuts

mmagic.models.editors.wgan_gp.wgan_gp_module

Module Contents

Classes

WGANNoiseTo2DFeat

Module used in WGAN-GP to transform 1D noise tensor in order [N, C] to

WGANDecisionHead

Module used in WGAN-GP to get the final prediction result with 4x4

ConvLNModule

ConvModule with Layer Normalization.

class mmagic.models.editors.wgan_gp.wgan_gp_module.WGANNoiseTo2DFeat(noise_size, out_channels, act_cfg=dict(type='ReLU'), norm_cfg=dict(type='BN'), order=('linear', 'act', 'norm'))[source]

Bases: torch.nn.Module

Module used in WGAN-GP to transform 1D noise tensor in order [N, C] to 2D shape feature tensor in order [N, C, H, W].

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

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

  • act_cfg (dict, optional) – Config for the activation layer. Defaults to dict(type=’ReLU’).

  • norm_cfg (dict, optional) – Config dict to build norm layer. Defaults to dict(type=’BN’).

  • order (tuple, optional) – The order of conv/norm/activation layers. It is a sequence of “conv”, “norm” and “act”. Common examples are (“conv”, “norm”, “act”) and (“act”, “conv”, “norm”). Defaults to (‘linear’, ‘act’, ‘norm’).

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input noise tensor with shape (n, c).

Returns

Forward results with shape (n, c, 4, 4).

Return type

Tensor

_init_weight()[source]

Initialize weights for the model.

class mmagic.models.editors.wgan_gp.wgan_gp_module.WGANDecisionHead(in_channels, mid_channels, out_channels, bias=True, act_cfg=dict(type='ReLU'), out_act=None, norm_cfg=dict(type='LN2d'))[source]

Bases: torch.nn.Module

Module used in WGAN-GP to get the final prediction result with 4x4 resolution input tensor in the bottom of the discriminator.

Parameters
  • in_channels (int) – Number of channels in input feature map.

  • mid_channels (int) – Number of channels in feature map after convolution.

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

  • bias (bool, optional) – Whether to use bias parameter. Defaults to True.

  • act_cfg (dict, optional) – Config for the activation layer. Defaults to dict(type=’ReLU’).

  • out_act (dict, optional) – Config for the activation layer of output layer. Defaults to None.

  • norm_cfg (dict, optional) – Config dict to build norm layer. Defaults to dict(type=’LN2d’).

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (n, c, h, w).

Returns

Forward results.

Return type

Tensor

_init_weight()[source]

Initialize weights for the model.

class mmagic.models.editors.wgan_gp.wgan_gp_module.ConvLNModule(*args, feature_shape=None, **kwargs)[source]

Bases: mmcv.cnn.ConvModule

ConvModule with Layer Normalization.

In this module, we inherit default mmcv.cnn.ConvModule and deal with the situation that ‘norm_cfg’ is ‘LN2d’ or ‘GN’. We adopt ‘GN’ as a replacement for layer normalization referring to: https://github.com/LynnHo/DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch/blob/master/module.py # noqa

Parameters

feature_shape (tuple) – The shape of feature map that will be.

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.