alibi_detect.models.tensorflow.autoencoder module
- class alibi_detect.models.tensorflow.autoencoder.AE(encoder_net, decoder_net, name='ae')[source]
Bases:
Model
- __init__(encoder_net, decoder_net, name='ae')[source]
Combine encoder and decoder in AE.
- Parameters:
encoder_net (
Model
) – Layers for the encoder wrapped in a tf.keras.Sequential class.decoder_net (
Model
) – Layers for the decoder wrapped in a tf.keras.Sequential class.name (
str
) – Name of autoencoder model.
- class alibi_detect.models.tensorflow.autoencoder.AEGMM(encoder_net, decoder_net, gmm_density_net, n_gmm, recon_features=<function eucl_cosim_features>, name='aegmm')[source]
Bases:
Model
- __init__(encoder_net, decoder_net, gmm_density_net, n_gmm, recon_features=<function eucl_cosim_features>, name='aegmm')[source]
Deep Autoencoding Gaussian Mixture Model.
- Parameters:
encoder_net (
Model
) – Layers for the encoder wrapped in a tf.keras.Sequential class.decoder_net (
Model
) – Layers for the decoder wrapped in a tf.keras.Sequential class.gmm_density_net (
Model
) – Layers for the GMM network wrapped in a tf.keras.Sequential class.n_gmm (
int
) – Number of components in GMM.recon_features (
Callable
) – Function to extract features from the reconstructed instance by the decoder.name (
str
) – Name of the AEGMM model.
- class alibi_detect.models.tensorflow.autoencoder.Decoder(decoder_net, name='decoder')[source]
Bases:
Layer
- class alibi_detect.models.tensorflow.autoencoder.DecoderLSTM(latent_dim, output_dim, output_activation=None, name='decoder_lstm')[source]
Bases:
Layer
- class alibi_detect.models.tensorflow.autoencoder.EncoderAE(encoder_net, name='encoder_ae')[source]
Bases:
Layer
- class alibi_detect.models.tensorflow.autoencoder.EncoderLSTM(latent_dim, name='encoder_lstm')[source]
Bases:
Layer
- class alibi_detect.models.tensorflow.autoencoder.EncoderVAE(encoder_net, latent_dim, name='encoder_vae')[source]
Bases:
Layer
- class alibi_detect.models.tensorflow.autoencoder.Sampling(*args, **kwargs)[source]
Bases:
Layer
Reparametrization trick. Uses (z_mean, z_log_var) to sample the latent vector z.
- class alibi_detect.models.tensorflow.autoencoder.Seq2Seq(encoder_net, decoder_net, threshold_net, n_features, score_fn=tensorflow.math.squared_difference, beta=1.0, name='seq2seq')[source]
Bases:
Model
- __init__(encoder_net, decoder_net, threshold_net, n_features, score_fn=tensorflow.math.squared_difference, beta=1.0, name='seq2seq')[source]
Sequence-to-sequence model.
- Parameters:
encoder_net (
EncoderLSTM
) – Encoder network.decoder_net (
DecoderLSTM
) – Decoder network.threshold_net (
Model
) – Regression network used to estimate threshold.n_features (
int
) – Number of features.score_fn (
Callable
) – Function used for outlier score.beta (
float
) – Weight on the threshold estimation loss term.name (
str
) – Name of the seq2seq model.
- class alibi_detect.models.tensorflow.autoencoder.VAE(encoder_net, decoder_net, latent_dim, beta=1.0, name='vae')[source]
Bases:
Model
- __init__(encoder_net, decoder_net, latent_dim, beta=1.0, name='vae')[source]
Combine encoder and decoder in VAE.
- Parameters:
encoder_net (
Model
) – Layers for the encoder wrapped in a tf.keras.Sequential class.decoder_net (
Model
) – Layers for the decoder wrapped in a tf.keras.Sequential class.latent_dim (
int
) – Dimensionality of the latent space.beta (
float
) – Beta parameter for KL-divergence loss term.name (
str
) – Name of VAE model.
- class alibi_detect.models.tensorflow.autoencoder.VAEGMM(encoder_net, decoder_net, gmm_density_net, n_gmm, latent_dim, recon_features=<function eucl_cosim_features>, beta=1.0, name='vaegmm')[source]
Bases:
Model
- __init__(encoder_net, decoder_net, gmm_density_net, n_gmm, latent_dim, recon_features=<function eucl_cosim_features>, beta=1.0, name='vaegmm')[source]
Variational Autoencoding Gaussian Mixture Model.
- Parameters:
encoder_net (
Model
) – Layers for the encoder wrapped in a tf.keras.Sequential class.decoder_net (
Model
) – Layers for the decoder wrapped in a tf.keras.Sequential class.gmm_density_net (
Model
) – Layers for the GMM network wrapped in a tf.keras.Sequential class.n_gmm (
int
) – Number of components in GMM.latent_dim (
int
) – Dimensionality of the latent space.recon_features (
Callable
) – Function to extract features from the reconstructed instance by the decoder.beta (
float
) – Beta parameter for KL-divergence loss term.name (
str
) – Name of the VAEGMM model.
- alibi_detect.models.tensorflow.autoencoder.eucl_cosim_features(x, y, max_eucl=100.0)[source]
Compute features extracted from the reconstructed instance using the relative Euclidean distance and cosine similarity between 2 tensors.
- Parameters:
x (
Tensor
) – Tensor used in feature computation.y (
Tensor
) – Tensor used in feature computation.max_eucl (
float
) – Maximum value to clip relative Euclidean distance by.
- Return type:
Tensor
- Returns:
Tensor concatenating the relative Euclidean distance and cosine similarity features.