Shortcuts

mmedit.models.base_archs.multi_layer_disc

Module Contents

Classes

MultiLayerDiscriminator

Multilayer Discriminator.

class mmedit.models.base_archs.multi_layer_disc.MultiLayerDiscriminator(in_channels: int, max_channels: int, num_convs: int = 5, fc_in_channels: Optional[int] = None, fc_out_channels: int = 1024, kernel_size: int = 5, conv_cfg: Optional[dict] = None, norm_cfg: Optional[dict] = None, act_cfg: Optional[dict] = dict(type='ReLU'), out_act_cfg: Optional[dict] = dict(type='ReLU'), with_input_norm: bool = True, with_out_convs: bool = False, with_spectral_norm: bool = False, **kwargs)[源代码]

Bases: torch.nn.Module

Multilayer Discriminator.

This is a commonly used structure with stacked multiply convolution layers.

参数
  • in_channels (int) – Input channel of the first input convolution.

  • max_channels (int) – The maximum channel number in this structure.

  • num_conv (int) – Number of stacked intermediate convs (including input conv but excluding output conv). Default to 5.

  • fc_in_channels (int | None) – Input dimension of the fully connected layer. If fc_in_channels is None, the fully connected layer will be removed. Default to None.

  • fc_out_channels (int) – Output dimension of the fully connected layer. Default to 1024.

  • kernel_size (int) – Kernel size of the conv modules. Default to 5.

  • conv_cfg (dict) – Config dict to build conv layer.

  • norm_cfg (dict) – Config dict to build norm layer.

  • act_cfg (dict) – Config dict for activation layer, “relu” by default.

  • out_act_cfg (dict) – Config dict for output activation, “relu” by default.

  • with_input_norm (bool) – Whether add normalization after the input conv. Default to True.

  • with_out_convs (bool) – Whether add output convs to the discriminator. The output convs contain two convs. The first out conv has the same setting as the intermediate convs but a stride of 1 instead of 2. The second out conv is a conv similar to the first out conv but reduces the number of channels to 1 and has no activation layer. Default to False.

  • with_spectral_norm (bool) – Whether use spectral norm after the conv layers. Default to False.

  • kwargs (keyword arguments) –

forward(x: torch.Tensor) torch.Tensor[源代码]

Forward Function.

参数

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

返回

Output tensor with shape of (n, c, h’, w’) or (n, c).

返回类型

torch.Tensor

init_weights(pretrained: Optional[str] = None) None[源代码]

Init weights for models.

参数

pretrained (str, optional) – Path for pretrained weights. If given None, pretrained weights will not be loaded. Defaults to None.

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.