text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

(in_train.shape, in_valid.shape, np.unique(out_train))

in_train = in_train / 255.0
in_valid = in_valid / 255.0

class_names = {index: cn for index, cn in enumerate(['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'])}

row_number = 5
def plot_train(n_rows=2, predictions=None):
    """create a grid with 10 columns
    """
    n_cols = 10
    images = in_train[:n_cols * n_rows]
    labels = out_train[:n_cols * n_rows]
    fig, axes = plt.subplots(n_rows, n_cols, figsize=(n_cols + 3, n_rows + 2))
    if predictions is None:
        predictions = [None] * len(labels)
    for index, (x, y_true, y_pred) in enumerate(zip(images, labels, predictions)):
        ax = axes.flat[index]
        ax.imshow(x, cmap=plt.cm.binary)
        ax.set_title(class_names[y_true])
        if y_pred is not None:
            ax.set_xlabel(class_names[y_pred])
        ax.set_xticks([])
        ax.set_yticks([])
plot_train(row_number)