alibi.models.pytorch.autoencoder module

This module contains a Pytorch general implementation of an autoencoder, by combining the encoder and the decoder module. In addition it provides an implementation of a heterogeneous autoencoder which includes a type checking of the output.

class alibi.models.pytorch.autoencoder.AE(encoder, decoder, **kwargs)[source]

Bases: Model

Autoencoder. Standard autoencoder architecture. The model is composed from two submodules, the encoder and the decoder. The forward pass consist of passing the input to the encoder, obtain the input embedding and pass the embedding through the decoder. The abstraction can be used for multiple data modalities.

__init__(encoder, decoder, **kwargs)[source]

Constructor. Combine encoder and decoder in AE.

Parameters:
  • encoder (Module) – Encoder network.

  • decoder (Module) – Decoder network.

forward(x)[source]

Forward pass.

Parameters:

x (Tensor) – Input tensor.

Return type:

Union[Tensor, List[Tensor]]

Returns:

x_hat – Reconstruction of the input tensor.

class alibi.models.pytorch.autoencoder.HeAE(encoder, decoder, **kwargs)[source]

Bases: AE

Heterogeneous autoencoder. The model follows the standard autoencoder architecture and includes and additional type check to ensure that the output of the model is a list of tensors. For more details, see alibi.models.pytorch.autoencoder.AE.

__init__(encoder, decoder, **kwargs)[source]

Constructor. Combine encoder and decoder in HeAE.

Parameters:
  • encoder (Module) – Encoder network.

  • decoder (Module) – Decoder network.

forward(x)[source]

Forward pass.

Parameters:

x (Tensor) – Input tensor.

Return type:

List[Tensor]

Returns:

List of reconstruction of the input tensor. First element corresponds to the reconstruction of all the numerical features if they exist, and the rest of the elements correspond to each categorical feature.