在 MNIST 数据集上训练的 CNN 在数字识别方面表现不佳

Poor performance on digit recognition with CNN trained on MNIST dataset

我使用 MNIST 数据集训练了 CNN(在 tensorflow 上)进行数字识别。 测试集的准确度接近 98%.

我想用自己创建的数据预测数字,结果很糟糕。

我对自己写的图做了什么?

我分割出每个数字并转换为灰度并将图像调整为 28x28 并提供给模型。

为什么我的数据集准确率如此之低,而测试集准确率如此之高?

我是否应该对图像进行其他修改?

编辑:

这里是 link 图片和一些例子:

排除错误和明显的错误,我的猜测是您的问题是您捕获手写数字的方式与您的训练集差别太大。

在捕获数据时,您应该尽量模仿用于创建 MNIST 数据集的过程:

来自oficial MNIST dataset website

The original black and white (bilevel) images from NIST were size normalized to fit in a 20x20 pixel box while preserving their aspect ratio. The resulting images contain grey levels as a result of the anti-aliasing technique used by the normalization algorithm. the images were centered in a 28x28 image by computing the center of mass of the pixels, and translating the image so as to position this point at the center of the 28x28 field.

如果您的数据在训练和测试阶段有不同的处理,那么您的模型无法从训练数据泛化到测试数据。

所以我有两个建议给你:

  1. 尝试捕获和处理您的数字图像,使它们看起来尽可能类似于 MNIST 数据集;
  2. 将您的一些示例添加到您的训练数据中,以允许您的模型在与您正在分类的图像相似的图像上进行训练;

对于那些仍然难以忍受基于 CNN 的 MNIST 模型质量低劣的人:

https://github.com/christiansoe/mnist_draw_test

规范化是关键。