alibi.models.tensorflow.cfrl_models module
This module contains the Tensorflow implementation of models used for the Counterfactual with Reinforcement Learning experiments for both data modalities (image and tabular).
- class alibi.models.tensorflow.cfrl_models.ADULTDecoder(hidden_dim, output_dims, **kwargs)[source]
Bases:
Model
ADULT decoder used in the Counterfactual with Reinforcement Learning experiments. The model consists of of a fully connected layer with ReLU nonlinearity, and a multiheaded layer, one for each categorical feature and a single head for the rest of numerical features. The hidden dimension used in the paper is 128.
- __init__(hidden_dim, output_dims, **kwargs)[source]
Constructor.
- Parameters:
hidden_dim (
int
) – Hidden dimension.output_dim – List of output dimensions.
- call(x, **kwargs)[source]
Forward pass.
- Parameters:
x (
Tensor
) – Input tensor.**kwargs – Other arguments. Not used.
- 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.
- class alibi.models.tensorflow.cfrl_models.ADULTEncoder(hidden_dim, latent_dim, **kwargs)[source]
Bases:
Model
ADULT encoder used in the Counterfactual with Reinforcement Learning experiments. The model consists of two fully connected layers with ReLU and tanh nonlinearities. The tanh nonlinearity clips the embedding in [-1, 1] as required in the DDPG algorithm (e.g., [act_low, act_high]). The layers’ dimensions used in the paper are 128 and 15, although those can vary as they were selected to generalize across many datasets.
- class alibi.models.tensorflow.cfrl_models.MNISTClassifier(output_dim=10, **kwargs)[source]
Bases:
Model
MNIST classifier used in the experiments for Counterfactual with Reinforcement Learning. The model consists of two convolutional layers having 64 and 32 channels and a kernel size of 2 with ReLU nonlinearities, followed by maxpooling of size 2 and dropout of 0.3. The convolutional block is followed by a fully connected layer of 256 with ReLU nonlinearity, and finally a fully connected layer is used to predict the class logits (10 in MNIST case).
- class alibi.models.tensorflow.cfrl_models.MNISTDecoder(**kwargs)[source]
Bases:
Model
MNIST decoder used in the Counterfactual with Reinforcement Learning experiments. The model consists of a fully connected layer of 128 units with ReLU activation followed by a convolutional block. The convolutional block consists fo 4 convolutional layers having 8, 8, 8 and 1 channels and a kernel size of 3. Each convolutional layer, except the last one, has ReLU nonlinearities and is followed by an up-sampling layer of size 2. The final layers uses a sigmoid activation to clip the output values in [0, 1].
- class alibi.models.tensorflow.cfrl_models.MNISTEncoder(latent_dim, **kwargs)[source]
Bases:
Model
MNIST encoder used in the experiments for the Counterfactual with Reinforcement Learning. The model consists of 3 convolutional layers having 16, 8 and 8 channels and a kernel size of 3, with ReLU nonlinearities. Each convolutional layer is followed by a maxpooling layer of size 2. Finally, a fully connected layer follows the convolutional block with a tanh nonlinearity. The tanh clips the output between [-1, 1], required in the DDPG algorithm (e.g., [act_low, act_high]). The embedding dimension used in the paper is 32, although this can vary.