Shortcuts

mmagic.models.archs.gated_conv_module

Module Contents

Classes

SimpleGatedConvModule

Simple Gated Convolutional Module.

class mmagic.models.archs.gated_conv_module.SimpleGatedConvModule(in_channels: int, out_channels: int, kernel_size: Union[int, Tuple[int, int]], feat_act_cfg: Optional[dict] = dict(type='ELU'), gate_act_cfg: Optional[dict] = dict(type='Sigmoid'), **kwargs)[source]

Bases: torch.nn.Module

Simple Gated Convolutional Module.

This module is a simple gated convolutional module. The detailed formula is:

\[y = \phi(conv1(x)) * \sigma(conv2(x)),\]

where phi is the feature activation function and sigma is the gate activation function. In default, the gate activation function is sigmoid.

Parameters
  • in_channels (int) – Same as nn.Conv2d.

  • out_channels (int) – The number of channels of the output feature. Note that out_channels in the conv module is doubled since this module contains two convolutions for feature and gate separately.

  • kernel_size (int or tuple[int]) – Same as nn.Conv2d.

  • feat_act_cfg (dict) – Config dict for feature activation layer. Default: dict(type=’ELU’).

  • gate_act_cfg (dict) – Config dict for gate activation layer. Default: dict(type=’Sigmoid’).

  • kwargs (keyword arguments) – Same as ConvModule.

forward(x: torch.Tensor) torch.Tensor[source]

Forward Function.

Parameters

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

Returns

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

Return type

torch.Tensor

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.