手写字符识别神经网络项目总结

1.数据集

手写字符数据集 DIGITS,该数据集的全称为 Pen-Based Recognition of Handwritten Digits Data Set,来源于 UCI 开放数据集网站。

2.加载数据集

import numpy as np

from sklearn import datasets

digits = datasets.load_digits()

3.分割数据集

from sklearn.model_selection import train_test_split

X, y = digits.data, digits.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=30)

  1. 搭建人工神经网络

from sklearn.neural_network import MLPClassifier

from sklearn.metrics import accuracy_score

def mpl():

model = MLPClassifier(hidden_layer_sizes=(100, 50), activation='relu', solver='sgd', learning_rate_init=0.02, max_iter=100, random_state=1)

model.fit(X_train, y_train)

y_pred = model.predict(X_test)

score = accuracy_score(y_test, y_pred)

return model, score

5.绘制损失变化曲线

model = mpl()0

plt.plot(model.loss_curve_)

相关推荐
远方的狮2 分钟前
机器人越来越多以后,谁来把它们组织起来?
人工智能
IT_陈寒3 分钟前
Vite静态资源导入这个坑我帮你们踩过了
前端·人工智能·后端
思考着亮20 分钟前
13.Agentic RAG -2
人工智能
u13013026 分钟前
AI 日报(2026年10月4日)
人工智能
飞塔老梅子34 分钟前
17. Unsloth下载、安装及加载本地大模型 ❀ 老梅子学AI
人工智能·glm·lm studio·5.3·unsolth
打工仔折腾 AI1 小时前
把AI Agent托管在家用电脑:UU远程终端与端口映射实测记录
人工智能·后端·python·langchain·ai agent 实战
零基础1231 小时前
Agent 的 Memory 怎么做科研:以中医诊断场景为例
人工智能·经验分享·python·语言模型
归秋1421 小时前
人声节奏对齐软件推荐:从专业DAW到AI人声制作工具怎么选
人工智能
2601_962966642 小时前
数学与应用数学专业想进管理咨询,2027届秋招需要补哪些商业知识和技能?
人工智能
ss2732 小时前
AI全栈实战 | 3.2-01 Python 基础:四大数据容器怎么选,推导式为什么是 Pythonic 的灵魂
开发语言·人工智能·python