Anchor explanations for fashion MNIST
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import Conv2D, Dense, Dropout, Flatten, MaxPooling2D, Input
from tensorflow.keras.models import Model
from tensorflow.keras.utils import to_categorical
from alibi.explainers import AnchorImageLoad and prepare fashion MNIST data
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()
print('x_train shape:', x_train.shape, 'y_train shape:', y_train.shape)x_train shape: (60000, 28, 28) y_train shape: (60000,)idx = 0
plt.imshow(x_train[idx]);
Define CNN model
Train model
Define superpixels

Define prediction function
Initialize anchor image explainer
Explain a prediction

Label
Description

Last updated
Was this helpful?

