在 mnist 数据集上训练时查看所有正确和错误识别的图像

See all correctly and incorrectly identified images when training on the mnist dataset

我正在尝试找到一种方法来可视化模型能够正确识别 mnist 数据集中的哪些数字以及不能正确识别哪些数字。 我似乎找不到的是在张量板上是否可以实现这种可视化,或者我是否需要 use/create 其他东西来实现它。

我目前正在使用为添加了 tensorboard 的 tensorflow 2.0 提供的 basic tutorial

import datetime
import tensorflow as tf

mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)

model.fit(x_train,
          y_train,
          epochs=5,
          validation_data=(x_test, y_test),
          callbacks=[tensorboard_callback])

model.evaluate(x_test, y_test)

看来假设工具正是我要找的东西,它允许您根据它是否 correctly or incorrectly identified by the model.

直观地对测试数据进行排序

如果你想测试一下here is their demo that I used to get the above image and they have multiple other demos on the tools site