Shortcuts

mmedit.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 mmedit.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'))[源代码]

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].

参数
  • 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)[源代码]

Forward function.

参数

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

返回

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

返回类型

Tensor

_init_weight()[源代码]

Initialize weights for the model.

class mmedit.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'))[源代码]

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.

参数
  • 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)[源代码]

Forward function.

参数

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

返回

Forward results.

返回类型

Tensor

_init_weight()[源代码]

Initialize weights for the model.

class mmedit.models.editors.wgan_gp.wgan_gp_module.ConvLNModule(*args, feature_shape=None, **kwargs)[源代码]

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

参数

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

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.