手寫識別實例,用神經網絡實現。
手寫識別是一個多分類任務,共有10個分類,即0-9。
圖像識別是指利用計算機對圖像進行處理、分析和理解,以識別各種不同模式的目標和對象的技術。一般經歷文字識別,數字圖像處理與識別和物體識別。
用DBRHD數據集,在這裏下載: http://archive.ics.uci.edu/ml/machine-learning-databases/pendigits/
折騰了半天,程序是運行成功了,但結果不對。另找了一篇文章,用sklearn自帶數據集digits。
https://blog.csdn.net/mcyjacky/article/details/85226752
coding:utf-8
神經網絡實現手寫識別
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import matplotlib.pyplot as plt
if name == "main":
# 加載數據
digits = load_digits()
x_data = digits.data
y_data = digits.target
print(x_data.shape)
print(y_data.shape)
# 劃分訓練測試集
x_train, x_test, y_train, y_test = train_test_split(x_data, y_data)
# 訓練
mlp = MLPClassifier(hidden_layer_sizes = (100, 50), max_iter = 500)
mlp.fit(x_train, y_train)
# 準確率評估
predictions = mlp.predict(x_test)
print(classification_report(y_test, predictions))
準確率蠻高。細節還不明白,先會用吧。
我發文章的四個地方,歡迎大家在朋友圈等地方分享,歡迎點“在看”。
我的個人博客地址:https://zwdnet.github.io
我的知乎文章地址: https://www.zhihu.com/people/zhao-you-min/posts
我的博客園博客地址: https://www.cnblogs.com/zwdnet/
我的微信個人訂閱號:趙瑜敏的口腔醫學學習園地