当前位置: 首页 > wzjs >正文

做搜狗网站排名软b2b网站大全免费推广

做搜狗网站排名软,b2b网站大全免费推广,门户网站团队建设,雅安城乡住房建设厅网站使用说明: ‌运行要求‌: MATLAB R2020b 或更新版本已安装 Deep Learning Toolbox推荐使用GPU加速(训练时在代码开头添加 gpuDevice(1)) ‌代码特点‌: 使用MATLAB自带的MNIST手写数字数据集包含数据可视化、网络架构…

使用说明:

  1. 运行要求‌:

    • MATLAB R2020b 或更新版本
    • 已安装 Deep Learning Toolbox
    • 推荐使用GPU加速(训练时在代码开头添加 gpuDevice(1)
  2. 代码特点‌:

    • 使用MATLAB自带的MNIST手写数字数据集
    • 包含数据可视化、网络架构、训练曲线和混淆矩阵
    • 最终测试准确率可达约98%
    • 包含单张图片预测演示

 

%% 神经网络OCR识别示例(MATLAB 2020b及以上版本)
% 需要安装 Deep Learning Toolbox%% 步骤1:加载和预处理数据
clc; clear; close all% 加载MATLAB自带的手写数字数据集
digitDatasetPath = fullfile(matlabroot, 'toolbox', 'nnet', 'nndemos', ...'nndatasets', 'DigitDataset');
imds = imageDatastore(digitDatasetPath, ...'IncludeSubfolders', true, 'LabelSource', 'foldernames');% 显示部分样本
figure
numImages = 10000;
perm = randperm(numImages, 20);
for i = 1:20subplot(4,5,i);imshow(imds.Files{perm(i)});
end% 分割数据集(70%训练,30%测试)
[imdsTrain, imdsTest] = splitEachLabel(imds, 0.7, 'randomized');%% 步骤2:构建神经网络
inputSize = [28 28 1]; % 输入图像尺寸layers = [imageInputLayer(inputSize, 'Name', 'input')   % 输入层convolution2dLayer(3, 16, 'Padding', 'same', 'Name', 'conv1') % 卷积层batchNormalizationLayer('Name', 'bn1')reluLayer('Name', 'relu1')maxPooling2dLayer(2, 'Stride', 2, 'Name', 'maxpool1') % 池化层convolution2dLayer(3, 32, 'Padding', 'same', 'Name', 'conv2')batchNormalizationLayer('Name', 'bn2')reluLayer('Name', 'relu2')fullyConnectedLayer(10, 'Name', 'fc')          % 全连接层softmaxLayer('Name', 'softmax')               % 分类层classificationLayer('Name', 'classification')];%% 步骤3:设置训练参数
options = trainingOptions('adam', ...'InitialLearnRate', 0.001, ...'MaxEpochs', 10, ...'Shuffle', 'every-epoch', ...'ValidationData', imdsTest, ...'ValidationFrequency', 30, ...'Verbose', true, ...'Plots', 'training-progress');%% 步骤4:调整图像大小并训练网络
augimdsTrain = augmentedImageDatastore(inputSize(1:2), imdsTrain);
augimdsTest = augmentedImageDatastore(inputSize(1:2), imdsTest);net = trainNetwork(augimdsTrain, layers, options);%% 步骤5:测试网络性能
[YPred, probs] = classify(net, augimdsTest);
accuracy = mean(YPred == imdsTest.Labels);
disp(['测试准确率: ', num2str(accuracy*100), '%'])% 显示混淆矩阵
figure
confusionchart(imdsTest.Labels, YPred)%% 步骤6:单张图片测试示例
% 随机选取测试集中的一个图像
testImage = readimage(imdsTest, randi(numel(imdsTest.Files)));% 预处理并预测
inputImg = imresize(testImage, inputSize(1:2));
[result, scores] = classify(net, inputImg);% 显示结果
figure
imshow(testImage)
title(['预测结果: ' char(result), '  真实标签: ' char(imdsTest.Labels(1))])
%% 神经网络OCR识别示例(MATLAB 2020b及以上版本)
% 需要安装 Deep Learning Toolbox%% 步骤1:加载和预处理数据
clc; clear; close all% 加载MATLAB自带的手写数字数据集
digitDatasetPath = fullfile(matlabroot, 'toolbox', 'nnet', 'nndemos', ...'nndatasets', 'DigitDataset');
imds = imageDatastore(digitDatasetPath, ...'IncludeSubfolders', true, 'LabelSource', 'foldernames');% 显示部分样本
figure
numImages = 10000;
perm = randperm(numImages, 20);
for i = 1:20subplot(4,5,i);imshow(imds.Files{perm(i)});
end% 分割数据集(70%训练,30%测试)
[imdsTrain, imdsTest] = splitEachLabel(imds, 0.7, 'randomized');%% 步骤2:构建神经网络
inputSize = [28 28 1]; % 输入图像尺寸layers = [imageInputLayer(inputSize, 'Name', 'input')   % 输入层convolution2dLayer(3, 16, 'Padding', 'same', 'Name', 'conv1') % 卷积层batchNormalizationLayer('Name', 'bn1')reluLayer('Name', 'relu1')maxPooling2dLayer(2, 'Stride', 2, 'Name', 'maxpool1') % 池化层convolution2dLayer(3, 32, 'Padding', 'same', 'Name', 'conv2')batchNormalizationLayer('Name', 'bn2')reluLayer('Name', 'relu2')fullyConnectedLayer(10, 'Name', 'fc')          % 全连接层softmaxLayer('Name', 'softmax')               % 分类层classificationLayer('Name', 'classification')];%% 步骤3:设置训练参数
options = trainingOptions('adam', ...'InitialLearnRate', 0.001, ...'MaxEpochs', 10, ...'Shuffle', 'every-epoch', ...'ValidationData', imdsTest, ...'ValidationFrequency', 30, ...'Verbose', true, ...'Plots', 'training-progress');%% 步骤4:调整图像大小并训练网络
augimdsTrain = augmentedImageDatastore(inputSize(1:2), imdsTrain);
augimdsTest = augmentedImageDatastore(inputSize(1:2), imdsTest);net = trainNetwork(augimdsTrain, layers, options);%% 步骤5:测试网络性能
[YPred, probs] = classify(net, augimdsTest);
accuracy = mean(YPred == imdsTest.Labels);
disp(['测试准确率: ', num2str(accuracy*100), '%'])% 显示混淆矩阵
figure
confusionchart(imdsTest.Labels, YPred)%% 步骤6:单张图片测试示例
% 随机选取测试集中的一个图像
testImage = readimage(imdsTest, randi(numel(imdsTest.Files)));% 预处理并预测
inputImg = imresize(testImage, inputSize(1:2));
[result, scores] = classify(net, inputImg);% 显示结果
figure
imshow(testImage)
title(['预测结果: ' char(result), '  真实标签: ' char(imdsTest.Labels(1))])

 

 

http://www.dtcms.com/wzjs/284941.html

相关文章:

  • 宁波广告公司网站建设优化模型
  • 今日疫情新闻发布会直播seo最新快速排名
  • 网站制作费会计分录怎么做在线葡京在线葡京
  • 长沙网站设计培训学校百度识图软件
  • 常州网络公司中环互联网网站建设短视频营销优势
  • java可以开发网站吗关键词分类哪八种
  • b to b网站建设模式seo英文怎么读
  • 城市建设网站可以全部免费观看的软件
  • 中国品牌网是什么网站it培训机构
  • 网站嵌入js百度知道
  • 深圳西乡网站建设公司seo快速入门教程
  • 做短视频的网站推广平台排名
  • 杭州 网站建设公司永久免费国外域名注册
  • 外汇网站开发商城系统开发
  • 哪个网站可以做卖房软文街官方网站
  • 顶尖文案网站佛山网站优化服务
  • wordpress 底部居中windows优化大师卸载不掉
  • 县电子政务办网站建设工作思路新闻发稿平台有哪些
  • 中山企业网站制作web网页模板
  • 小辣椒网站开发百度一下进入首页
  • 快速装修公司焦作seo公司
  • 酒店网站建设案例广州网站排名优化报价
  • 成都家居网站建设营业推广是什么
  • python做网站教程重庆seo外包平台
  • 郑州网站制作服务今天重大新闻头条
  • 网站的大小郑州网站排名优化公司
  • 网站设计基础语言不包括这些内容windows优化大师是病毒吗
  • 网站定位分析百度官方官网
  • 动态网站可以用dw做吗域名污染查询网站
  • jsp网站建设王通seo