kamangir
fashion-mnist -> image-classifier - kamangir/bolt#689
fc0b387
raw
history blame
1.27 kB
from abcli import string
import matplotlib.pyplot as plt
import numpy as np
import abcli.logging
import logging
logger = logging.getLogger(__name__)
def plot_image(i, predictions_array, true_label, image, class_names):
plt.grid(False)
plt.xticks([])
plt.yticks([])
plt.imshow(image[i], cmap=plt.cm.binary)
predicted_label = np.argmax(predictions_array)
if true_label is None:
color = "black"
elif predicted_label == true_label[i]:
color = "blue"
else:
color = "red"
plt.xlabel(
"{} {:2.0f}%{}".format(
string.shorten(class_names[predicted_label]),
100 * np.max(predictions_array),
""
if true_label is None
else " ({})".format(string.shorten(class_names[true_label[i]])),
),
color=color,
)
def plot_value_array(i, predictions_array, true_label):
plt.grid(False)
plt.xticks(range(len(predictions_array)))
plt.yticks([])
handle = plt.bar(range(len(predictions_array)), predictions_array, color="#777777")
plt.ylim([0, 1])
predicted_label = np.argmax(predictions_array)
handle[predicted_label].set_color("green")
if true_label is not None:
handle[true_label[i]].set_color("blue")