ml4gw.nn.autoencoder.convolutional

Classes

ConvBlock(in_channels, encode_channels, ...)

Convolutional encoder-decoder block.

ConvolutionalAutoencoder(in_channels, ...[, ...])

Build a stack of convolutional autoencoder layer blocks.

class ml4gw.nn.autoencoder.convolutional.ConvBlock(in_channels, encode_channels, kernel_size, stride=1, groups=1, activation=<class 'torch.nn.modules.activation.ReLU'>, norm=<class 'torch.nn.modules.batchnorm.BatchNorm1d'>, decode_channels=None, output_activation=None, skip_connection=None)

Bases: Autoencoder

Convolutional encoder-decoder block.

Parameters:
  • in_channels (int) -- Number of input channels.

  • encode_channels (int) -- Number of channels produced by the encoder per group.

  • kernel_size (int) -- Size of the convolution kernels.

  • stride (int) -- Stride used by the encoder and decoder.

  • groups (int) -- Number of blocked channel connections.

  • activation (Callable[..., Module]) -- Module constructor used after intermediate layers.

  • norm (Callable[..., Module]) -- Normalization module constructor.

  • decode_channels (int | None) -- Number of channels produced by the decoder.

  • output_activation (Callable[..., Module] | None) -- Module constructor used after the decoder. Uses activation when omitted.

  • skip_connection (SkipConnection | None) -- Skip connection applied before decoding.

decode(X)
Return type:

Tensor

Parameters:

X (Tensor)

encode(X)
Return type:

Tensor

Parameters:

X (Tensor)

class ml4gw.nn.autoencoder.convolutional.ConvolutionalAutoencoder(in_channels, encode_channels, kernel_size, stride=1, groups=1, activation=<class 'torch.nn.modules.activation.ReLU'>, output_activation=None, norm=<class 'torch.nn.modules.batchnorm.BatchNorm1d'>, decode_channels=None, skip_connection=None)

Bases: Autoencoder

Build a stack of convolutional autoencoder layer blocks. The output of each decoder layer will match the shape of the input to its corresponding encoder layer, except for the last decoder which can have an arbitrary number of channels specified by decode_channels.

All layers also share the same activation except for the last decoder layer, which can have an arbitrary output_activation.

Parameters:
  • in_channels (int)

  • encode_channels (Sequence[int])

  • kernel_size (int)

  • stride (int)

  • groups (int)

  • activation (Callable[[...], Module])

  • output_activation (Callable[[...], Module] | None)

  • norm (Callable[[...], Module])

  • decode_channels (int | None)

  • skip_connection (SkipConnection | None)

decode(*X, states=None, input_size=None)
Return type:

Tensor

Parameters:

input_size (int | None)

forward(X)
Return type:

Tensor

Parameters:

X (Tensor)