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

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_)

相关推荐
SuniaWang5 小时前
《Spring AI + 大模型全栈实战》学习手册系列 · 专题六:《Vue3 前端开发实战:打造企业级 RAG 问答界面》
java·前端·人工智能·spring boot·后端·spring·架构
IDZSY04306 小时前
AI社交平台进阶指南:如何用AI社交提升工作学习效率
人工智能·学习
七七powerful6 小时前
运维养龙虾--AI 驱动的架构图革命:draw.io MCP 让运维画图效率提升 10 倍,使用codebuddy实战
运维·人工智能·draw.io
水星梦月6 小时前
大白话讲解AI/LLM核心概念
人工智能
温九味闻醉6 小时前
关于腾讯广告算法大赛2025项目分析1 - dataset.py
人工智能·算法·机器学习
White-Legend6 小时前
第三波GPT5.4 日400刀
人工智能·ai编程
. . . . .6 小时前
Claude Code Hooks的原理、触发执行机制以及如何编写 Hooks
人工智能
w_t_y_y6 小时前
codex(一)下载安装&使用
人工智能
老鱼说AI6 小时前
大规模并发处理器程序设计(PMPP)讲解(CUDA架构):第四期:计算架构与调度
c语言·深度学习·算法·架构·cuda