Units

class ezflow.modules.units.Conv2x(in_channels, out_channels, deconv=False, concat=True, norm='batch', activation='relu')[source]

Double convolutional layer with the option to perform deconvolution and concatenation

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • deconv (bool) – Whether to perform deconvolution instead of convolution

  • concat (bool) – Whether to concatenate the input and the output of the first convolution layer

  • norm (str) – Type of normalization to use. Can be “batch”, “instance”, “group”, or “none”

  • activation (str) – Type of activation to use. Can be “relu” or “leakyrelu”

forward(x, rem)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class ezflow.modules.units.ConvNormRelu(in_channels, out_channels, deconv=False, norm='batch', activation='relu', **kwargs)[source]

Block for a convolutional layer with normalization and activation

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • deconv (bool, optional) – If True, use a transposed convolution

  • norm (str, optional) – Normalization method

  • activation (str, optional) – Activation function

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

ezflow.modules.units.conv(in_channels, out_channels, kernel_size=3, stride=1, padding=1, dilation=1, norm=None)[source]

2D convolution layer with optional normalization followed by an inplace LeakyReLU activation of 0.1 negative slope.

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • kernel_size (int, default: 3) – Size of the convolutional kernel

  • stride (int, default: 1) – Stride of the convolutional kernel

  • padding (int, default: 1) – Padding of the convolutional kernel

  • dilation (int, default: 1) – Dilation of the convolutional kernel

  • norm (str, default: None) – Type of normalization to use. Can be None, ‘batch’, ‘layer’, ‘group’

ezflow.modules.units.deconv(in_channels, out_channels, kernel_size=4, stride=2, padding=1)[source]

2D transpose convolution layer followed by an activation function

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • kernel_size (int, optional) – Size of the convolutional kernel

  • stride (int, optional) – Stride of the convolutional kernel

  • padding (int, optional) – Padding of the convolutional kernel

  • dilation (int, optional) – Dilation of the convolutional kernel