alibi.models.tensorflow.autoencoder module

This module contains a Tensorflow 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.tensorflow.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 consists 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 (Model) – Encoder network.

  • decoder (Model) – Decoder network.

call(x, **kwargs)[source]

Forward pass.

Parameters:
  • x (Tensor) – Input tensor.

  • **kwargs – Other arguments passed to encoder/decoder call method.

Return type:

Union[Tensor, List[Tensor]]

Returns:

x_hat – Reconstruction of the input tensor.

class alibi.models.tensorflow.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 (Model) – Encoder network.

  • decoder (Model) – Decoder network.

build(input_shape)[source]

Build method.

Parameters:

input_shape (Tuple[int, ...]) – Tensor’s input shape.

Return type:

None

call(x, **kwargs)[source]

Forward pass.

Parameters:
  • x (Tensor) – Input tensor.

  • **kwargs – Other arguments passed to the encoder/decoder.

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.