手写数字识别(慕课MOOC人工智能之模式识别)

问题:手写数字识别

数据集

数据集链接请点击我

代码

matlab 复制代码
%mat2vector.m
function [data_]= mat2vector(data,num)
    [row,col,~]= size(data);
    data_=zeros(num,row*col);
    for page =1:num
        for rows =1:row
            for cols=1:col
                data_(page,((rows-1)*col+cols))= im2double(data(rows,cols,page));
            end
        end
    end
end
matlab 复制代码
image = cell(1,10);
for i= 0:9
    filename = sprintf('E:/fig/model/%d.bmp',i);
    image{1,i+1} = mat2vector(imresize(imread(filename),[28,28]),1);
end

correct_num=0;
for index = 0:9
    distance =zeros(1,10);
    fname=sprintf('E:/fig/test/%d.1.bmp',index);
    sample =mat2vector(imresize(imread(fname),[28,28]),1);
    for j= 1:10
        distance(j)=pdist2(sample,image{1,j},'euclidean');
    end
    [m,p]= min(distance);
    if p-1==index
        correct_num=correct_num+1;
    end
    fprintf('数字%d到模板的最小距离为:%d,匹配到的类别为:%d\n',[index,m,p-1]);
end
fprintf('共测试10个样本,正确匹配个数为%d个\n',correct_num);

执行结果

补充(数据集文件夹的注意事项)



有问题联系xylwork@yeah.net

相关推荐
凤希AI伴侣2 小时前
你觉得,AI能让你“一人成军”吗?我的工具流与真实体验
人工智能·凤希ai伴侣
23遇见2 小时前
从底层到落地:cann/ops-nn 算子库的技术演进与实践
人工智能
DeanWinchester_mh2 小时前
DeepSeek新论文火了:不用卷算力,一个数学约束让大模型更聪明
人工智能·学习
dixiuapp2 小时前
学校后勤报修系统哪个好,如何选择
大数据·人工智能·工单管理系统·院校工单管理系统·物业报修系统
魔乐社区2 小时前
MindSpeed LLM适配Qwen3-Coder-Next并上线魔乐社区,训练推理教程请查收
人工智能·深度学习·机器学习
大傻^2 小时前
混合专家系统(MoE)深度解析:从原理到Mixtral AI工程实践
人工智能·混合专家系统·mixtral ai
code bean2 小时前
【AI 】OpenSpec 实战指南:在 Cursor 中落地 AI 原生开发工作流
人工智能·cursor·ai工作流·openspec
多恩Stone2 小时前
【3D AICG 系列-6】OmniPart 训练流程梳理
人工智能·pytorch·算法·3d·aigc
江瀚视野2 小时前
多家银行向甲骨文断贷,巨头甲骨文这是怎么了?
大数据·人工智能
ccLianLian2 小时前
计算机基础·cs336·损失函数,优化器,调度器,数据处理和模型加载保存
人工智能·深度学习·计算机视觉·transformer