clear
clc
close all
rng(1)
%% 1. 准备
imds = imageDatastore('CNN/', ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames'); % 图像数据集
targets = xlsread("整合最终.xls") ;
targets(121:122,:)=[];
[out,ps] = mapminmax(targets(:,end)');
targets = out;
XTrain = zeros(74,144,3,100);
XValidation = zeros(74,144,3,20);
YTrain = zeros(100,1);
YValidation = zeros(20,1);
idx = randperm(120);
t = 1;
for i = idx
img = im2double(imread(imds.Files{i}));
% img = (img - min(img(:))) / (max(img(:)) - min(img(:)));
if t <=100 % 训练集
XTrain(:,:,:,t) = img;
YTrain(t) = targets(i);
XValidation(:,:,:,t) = img;
YValidation(t) = targets(i);
else
XValidation(:,:,:,t) = img;
YValidation(t) = targets(i);
end
t = t+1;
end
%% 2.定义网络架构
layers = [
imageInputLayer([74 144 3],"Name","imageinput")
convolution2dLayer([3 3],32,"Name","Conv2d_1","Padding","same")
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2); % 37 72
convolution2dLayer([3 3],64,"Name","Conv2d_2","Padding","same")
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2); % 18 36
convolution2dLayer([3 3],32,"Name","Conv2d_3","Padding","same")
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2); % 9 18
fullyConnectedLayer(512,"Name","fc1")
reluLayer
dropoutLayer(0.09)
fullyConnectedLayer(256,"Name","fc2")
reluLayer
fullyConnectedLayer(1)
regressionLayer];
analyzeNetwork(layers)
%% 3.训练网络
% 指定训练选项并训练网络。
options = trainingOptions('adam', ...
'MiniBatchSize', 2, ...
'MaxEpochs', 20, ...
'InitialLearnRate', 1e-5, ...
'LearnRateSchedule', 'piecewise', ...
'LearnRateDropFactor', 0.1, ...
'LearnRateDropPeriod', 20, ...
'Shuffle', 'every-epoch', ...
'Plots', 'training-progress', ...
'Verbose', true);
net = trainNetwork(XTrain,YTrain, layers,options);
%% 4.测试网络
YPredict = predict(net,XValidation);
YPredict = mapminmax('reverse',YPredict',ps);
YValidation = mapminmax('reverse',YValidation',ps);
figure;
plot(YPredict,'-o','LineWidth',1.5);hold on
plot(YValidation,'--*','LineWidth',1.5);
legend('预测','事实')
[MSE, RMSE, MBE, MAE ] =MSE_RMSE_MBE_MAE(YValidation,YPredict)
R2 = R_2(YValidation,YPredict)
R2 = R_2(YValidation(101:end),YPredict(101:end))
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于MATLAB编程实现,用卷积神经网络实现对图像集的批量识别,卷积神经网络结构完整,可以输出卷积神经网络的结构,和训练过程,上传包括完整的M文件和数据,代码可以直接运行,代码比较精简,同时结构复杂,处理能力好,方便后期扩展到其他数据
资源推荐
资源详情
资源评论
收起资源包目录
基于卷积神经网络CNN的图像识别,基于卷积神经网络的图像评价 (127个子文件)
Frame_00038.bmp 42KB
Frame_00032.bmp 42KB
Frame_00096.bmp 42KB
Frame_00003.bmp 42KB
Frame_00082.bmp 42KB
Frame_00061.bmp 42KB
Frame_00049.bmp 42KB
Frame_00115.bmp 42KB
Frame_00045.bmp 42KB
Frame_00118.bmp 42KB
Frame_00074.bmp 42KB
Frame_00060.bmp 42KB
Frame_00064.bmp 42KB
Frame_00057.bmp 42KB
Frame_00034.bmp 42KB
Frame_00062.bmp 42KB
Frame_00041.bmp 42KB
Frame_00106.bmp 42KB
Frame_00112.bmp 42KB
Frame_00088.bmp 42KB
Frame_00101.bmp 42KB
Frame_00089.bmp 42KB
Frame_00001.bmp 42KB
Frame_00036.bmp 42KB
Frame_00058.bmp 42KB
Frame_00012.bmp 42KB
Frame_00083.bmp 42KB
Frame_00004.bmp 42KB
Frame_00037.bmp 42KB
Frame_00076.bmp 42KB
Frame_00052.bmp 42KB
Frame_00011.bmp 42KB
Frame_00105.bmp 42KB
Frame_00104.bmp 42KB
Frame_00020.bmp 42KB
Frame_00023.bmp 42KB
Frame_00069.bmp 42KB
Frame_00079.bmp 42KB
Frame_00119.bmp 42KB
Frame_00063.bmp 42KB
Frame_00027.bmp 42KB
Frame_00010.bmp 42KB
Frame_00042.bmp 42KB
Frame_00094.bmp 42KB
Frame_00007.bmp 42KB
Frame_00109.bmp 42KB
Frame_00090.bmp 42KB
Frame_00024.bmp 42KB
Frame_00100.bmp 42KB
Frame_00070.bmp 42KB
Frame_00107.bmp 42KB
Frame_00108.bmp 42KB
Frame_00039.bmp 42KB
Frame_00054.bmp 42KB
Frame_00014.bmp 42KB
Frame_00080.bmp 42KB
Frame_00021.bmp 42KB
Frame_00050.bmp 42KB
Frame_00015.bmp 42KB
Frame_00019.bmp 42KB
Frame_00092.bmp 42KB
Frame_00025.bmp 42KB
Frame_00033.bmp 42KB
Frame_00048.bmp 42KB
Frame_00002.bmp 42KB
Frame_00044.bmp 42KB
Frame_00035.bmp 42KB
Frame_00116.bmp 42KB
Frame_00030.bmp 42KB
Frame_00046.bmp 42KB
Frame_00071.bmp 42KB
Frame_00006.bmp 42KB
Frame_00065.bmp 42KB
Frame_00097.bmp 42KB
Frame_00016.bmp 42KB
Frame_00059.bmp 42KB
Frame_00000.bmp 42KB
Frame_00056.bmp 42KB
Frame_00026.bmp 42KB
Frame_00072.bmp 42KB
Frame_00102.bmp 42KB
Frame_00055.bmp 42KB
Frame_00085.bmp 42KB
Frame_00013.bmp 42KB
Frame_00098.bmp 42KB
Frame_00005.bmp 42KB
Frame_00103.bmp 42KB
Frame_00117.bmp 42KB
Frame_00040.bmp 42KB
Frame_00047.bmp 42KB
Frame_00086.bmp 42KB
Frame_00099.bmp 42KB
Frame_00051.bmp 42KB
Frame_00053.bmp 42KB
Frame_00018.bmp 42KB
Frame_00084.bmp 42KB
Frame_00043.bmp 42KB
Frame_00113.bmp 42KB
Frame_00081.bmp 42KB
Frame_00009.bmp 42KB
共 127 条
- 1
- 2
资源评论
- 一帆风顺7122023-12-01实在是宝藏资源、宝藏分享者!感谢大佬~
- ~安丢丢~2023-12-01终于找到了超赞的宝藏资源,果断冲冲冲,支持!
- 猫瘾1042024-01-14资源是宝藏资源,实用也是真的实用,感谢大佬分享~
- niping3212023-12-27这个资源值得下载,资源内容详细全面,与描述一致,受益匪浅。
- JOCKERIGHT2024-02-21实在是宝藏资源、宝藏分享者!感谢大佬~
神经网络机器学习智能算法画图绘图
- 粉丝: 2800
- 资源: 659
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功