python - 如何教卷积神经网络对未知图像说 "no"?

标签 python machine-learning keras ocr image-recognition

我有字符识别的任务。有一定的数据集。当我提交不是来自该数据集的输入符号(或一个图像中数据集中的一组字符)时,神经网络会选择最相似的符号。在这种情况下,网络应该说她不知道这样的符号。 可能有任何架构可以完成此任务吗?

我正在使用 Keras(Tensorlow 作为后端)使用 Python 3 进行编写。

我的架构:

Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 29, 29, 75)        1275      
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 14, 14, 75)        0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 14, 14, 75)        0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 11, 11, 100)       120100    
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 5, 5, 100)         0         
_________________________________________________________________
dropout_2 (Dropout)          (None, 5, 5, 100)         0         
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 2, 2, 125)         200125    
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 1, 1, 125)         0         
_________________________________________________________________
dropout_3 (Dropout)          (None, 1, 1, 125)         0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 125)               0         
_________________________________________________________________
dense_1 (Dense)              (None, 500)               63000     
_________________________________________________________________
dropout_4 (Dropout)          (None, 500)               0         
_________________________________________________________________
dense_2 (Dense)              (None, 69)                34569     

最佳答案

最好的方法是:

  1. 使用数据集中对应于“未知”类的附加图像,您可以通过对类似符号的字符图像进行采样来获取该图像。然后针对“n+1”个类别训练模型,其中“n”是您当前正在处理的类别数。

  2. 仔细查看 softmax 输出并启发式选择阈值。

关于python - 如何教卷积神经网络对未知图像说 "no"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49242180/

相关文章:

python - 蜘蛛scrapy中的读取设置

tensorflow - keras中的fit_generator : where is the batch_size specified?

python - 如何知道reportlab PDF 页面是否已满?

python - Selenium Webdriver 错误 : "Can' t load the profile"

python - 如何在 numpy python 中创建相似度矩阵?

tensorflow 2.3 - 'Keyword argument not understood:' , 'input'

machine-learning - 使用自动学习重构决策树

python - 运行时错误: CorrMM failed to allocate working memory of 576 x 50176

deep-learning - Keras ImageDataGenerator 未按预期工作

python - 从具有不同键但相同 id 的现有字典创建新的 python 字典