簡體   English   中英

簡單的(有效的)手寫數字識別:如何改進?

[英]Simple (working) handwritten digit recognition: how to improve it?

我只是寫了這個非常簡單的手寫數字識別。 這是8kb存檔,其中包含以下代碼+十個.PNG圖像文件。 有用: 在此處輸入圖片說明 被公認為 在此處輸入圖片說明

簡而言之,數據庫的每個數字(50x50像素= 250個系數)被匯總為一個10系數向量(通過保留10個最大的奇異值,請參見SVD的低秩近似 )。

然后為了識別數字,我們將距離與數據庫中的數字最小化。

from scipy import misc
import numpy as np
import matplotlib.pyplot as plt

digits = []
for i in range(11):
    M = misc.imread(str(i) + '.png', flatten=True)
    U, s, V = np.linalg.svd(M, full_matrices=False)
    s[10:] = 0        # keep the 10 biggest singular values only, discard others
    S = np.diag(s)
    M_reduced = np.dot(U, np.dot(S, V))      # reconstitution of image with 10 biggest singular values
    digits.append({'original': M, 'singular': s[:10], 'reduced': M_reduced})

# each 50x50 pixels digit is summarized into a vector of 10 coefficients : the 10 biggest singular values s[:10]    

# 0.png to 9.png = all the digits (for machine training)
# 10.png = the digit to be recognized
toberecognizeddigit = digits[10]    
digits = digits[:10]

# we find the nearest-neighbour by minimizing the distance between singular values of toberecoginzeddigit and all the digits in database
recognizeddigit = min(digits[:10], key=lambda d: sum((d['singular']-toberecognizeddigit['singular'])**2))    

plt.imshow(toberecognizeddigit['reduced'], interpolation='nearest', cmap=plt.cm.Greys_r)
plt.show()
plt.imshow(recognizeddigit['reduced'], interpolation='nearest', cmap=plt.cm.Greys_r)
plt.show()

題:

該代碼有效(您可以在ZIP存檔中運行該代碼),但是我們如何才能對其進行改進以獲得更好的結果? (我想象中的大多數是數學技術)。

例如,在我的測試中,9和3有時會相互混淆。

數字識別可能是一個相當困難的領域。 尤其是當數字以完全不同或不清楚的方式書寫時。 為了解決這個問題,已經采取了許多方法,並且整個競爭都致力於這一主題。 有關示例,請參見Kaggle的數字識別器競賽 這項競賽基於眾所周知的MNIST數據集 在那里的論壇中,您會找到很多解決此問題的想法和方法,但是我會給出一些快速的建議。

許多人將此問題視為分類問題。 解決此類問題的可能算法包括,例如kNN,神經網絡或梯度提升。

然而,通常僅算法不足以獲得最佳分類率。 改善分數的另一個重要方面是特征提取。 想法是計算可以區分不同數字的特征。 該數據集的一些示例功能可能包括彩色像素的數量,或者數字的寬度和高度。

盡管其他算法可能不是您要找的算​​法,但是添加更多功能可能也可以改善當前使用的算法的性能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM