Counterfactual with Reinforcement Learning (CFRL) on MNIST
pip install alibi[tensorflow]import os
import numpy as np
import matplotlib.pyplot as plt
from typing import Dict
import tensorflow as tf
import tensorflow.keras as keras
from alibi.explainers import CounterfactualRL
from alibi.models.tensorflow import AE
from alibi.models.tensorflow import Actor, Critic
from alibi.models.tensorflow import MNISTEncoder, MNISTDecoder, MNISTClassifier
from alibi.explainers.cfrl_base import CallbackLoad MNIST dataset
Define and train CNN classifier
Define the predictor (black-box)
Define and train autoencoder
Test the autoencoder

Counterfactual with Reinforcement Learning
Define and fit the explainer
Test explainer

Logging
Logging reward callback
Logging images callback
Logging losses callback
Last updated
Was this helpful?

