MNIST分类器在非MNIST数字上失败

问题描述 投票:-2回答:1

我刚刚意识到,我的MNIST数字分类器(一个卷积神经网络)在我自己的手绘数字上失败了,准确度大约为55%(黑白图像为50%,白图像为60% -黑色图像)。

考虑到工业字符识别软件对于全新字符非常准确,因此结果令我感到惊讶。

我能够在网上找到的唯一解释就是过拟合,这似乎不太可能,因为我的模型具有98.4%的测试准确度。另一种解释是,MNIST数据集的维度实际上并不像人们希望的那样低/维数较低,这似乎不太可能。转换为灰度也不是问题(请参阅Roshin的回答下的评论)。

谁愿意看看我的模型并告诉我怎么了?我自己的角色的测试在最后一个填充的单元格中。

tensorflow machine-learning neural-network conv-neural-network mnist
1个回答
0
投票

问题出在线路上:

# my own hand-drawn characters
with url.urlopen(img) as file:
  x2 = im.imread(file.read())
# average color channels, put in 1-size batch, normalize
x2 = np.array([[[[np.mean(entry)] for entry in row] for row in x2]]) / 255.0

您应该将图像转换为灰度。

# my own hand-drawn characters
with url.urlopen(img) as file:
  pil_im = Image.open(file.read()).convert('L')
  img = np.array(pil_im) / 255.0
# average color channels, put in 1-size batch, normalize

您应该事先从Image导入PIL模块,

from PIL import Image
© www.soinside.com 2019 - 2024. All rights reserved.