微前端架构如何改变企业的开发模式与效率提升
723
2022-11-08
matlab 神经网络 ANN 分类
1、内容简介
略 500-可以交流、咨询、答疑
2、内容说明
clear clc close all %% import and deal data filename = "DAY 1-DAY28 AVERAGE DATA SETS----A.B.C -split by 28 × 6 classification.xlsx"; datatrain = xlsread(filename, "Sheet1"); datatest = xlsread(filename, "Sheet2"); datavalidation = xlsread(filename, "Sheet3"); Xtrain = datatrain(:,1:4)'; % Xtrain(2,:) = 100*Xtrain(2,:); Ytrain = datatrain(:,5)'; [~,nber] = size(Xtrain); order = randperm(nber); XTrain1 = Xtrain(:,order); YTrain1 = Ytrain(:,order);
XValidation = datavalidation(:,1:4)'; % XValidation(2,:) = 100*XValidation(2,:); YValidation = datavalidation(:,5)'; [~,nber] = size(XValidation); order = randperm(nber); XValidation1 = XValidation(:,order); YValidation1 = YValidation(:,order);
Xtest = datatest(:,1:4)'; % Xtest(2,:) = 100*Xtest(2,:); Ytest = datatest(:,5)'; [~,nber] = size(Xtest); order = randperm(nber); Xtest1 = Xtest(:,order); Ytest1 = Ytest(:,order);
XTrain = [XTrain1 XValidation1 Xtest1]; YTrain = [YTrain1 YValidation1 Ytest1];
% [p1,minp,maxp,t1,mint,maxt]=premnmx(XTrain,YTrain); % load net.mat % accuary(net, XTrain, YTrain, minp, maxp, mint,maxt) % accuary(net, XValidation, YValidation, minp, maxp, mint,maxt) % accuary(net, Xtest, Ytest, minp, maxp, mint,maxt) %% 训练 %数据做归一化 % [p1,minp,maxp,t1,mint,maxt]=premnmx(XTrain,output'); [p1,minp,maxp,t1,mint,maxt]=premnmx(XTrain,YTrain); %创建网络 % logsig:对数S形转移函数,单极性;tansig: 双极性S形转移函数;purelin:线性函数 % traingdx :梯度下降自适应学习率训练函数,traingdm,trainlm, trainscg 这些是权值的学习算法 % traingdm是带动量的梯度下降法,trainlm是指L-M优化算法,trainscg是指量化共轭梯度法 % 网络结构:三个隐含层、且神经元数分别为5、12的前向BP网络,1个output % net=newff(minmax(p1),[6, 15, 1],{'tansig', 'tansig','purelin'},'trainlm'); net=newff(minmax(p1),[12, 24, 32, 24, 1],{'tansig', 'tansig', 'tansig', 'tansig', 'purelin'},'trainlm'); % net=newff(minmax(p1),[5, 12, 3],{'tansig', 'tansig','purelin'},'trainlm'); %设置训练次数 net.trainParam.epochs = 600; %设置收敛误差 net.trainParam.goal=0.0001; %设置学习率 net.trainParam.lr = 0.03 ; %设置动量因子,避免局部最优和过拟合 net.trainParam.mc=0.9; %最小确认失败次数 net.trainParam.max_fail=30; %训练网络 [net,tr]=train(net,p1,t1); %% fuse_matrix_train = accuary(net, XTrain, YTrain, minp, maxp, mint,maxt); fuse_matrix_Validation = accuary(net, XValidation, YValidation, minp, maxp, mint,maxt); fuse_matrix_test = accuary(net, Xtest, Ytest, minp, maxp, mint,maxt);
%% figure imagesc(fuse_matrix_train) set(gca,'xtick',1:3) set(gca,'xticklabel',{'1 ','2','3'},'XTickLabelRotation',45) set(gca,'ytick',1:3) set(gca,'yticklabel',{'1 ','2','3'}) set(gca,'FontSize',14,'Fontname', 'Times New Roman'); colorbar title ("train data") xlabel('truth') ylabel("predict") [m,n] = size(fuse_matrix_train); for i = 1:m for j = 1:n x = i; y = j; text(x,y,num2str(fuse_matrix_train(i,j))) end end
% figure imagesc(fuse_matrix_Validation) set(gca,'xtick',1:3) set(gca,'xticklabel',{'1 ','2','3'},'XTickLabelRotation',45) set(gca,'ytick',1:3) set(gca,'yticklabel',{'1 ','2','3'}) set(gca,'FontSize',14,'Fontname', 'Times New Roman'); colorbar title ("Validation data") xlabel('truth') ylabel("predict") [m,n] = size(fuse_matrix_Validation); for i = 1:m for j = 1:n x = i; y = j; text(x,y,num2str(fuse_matrix_Validation(i,j))) end end % figure imagesc(fuse_matrix_test) set(gca,'xtick',1:3) set(gca,'xticklabel',{'1 ','2','3'},'XTickLabelRotation',45) set(gca,'ytick',1:3) set(gca,'yticklabel',{'1 ','2','3'}) set(gca,'FontSize',14,'Fontname', 'Times New Roman'); colorbar title ("test data") xlabel('truth') ylabel("predict") [m,n] = size(fuse_matrix_test); for i = 1:m for j = 1:n x = i; y = j; text(x,y,num2str(fuse_matrix_test(i,j))) end end
3、仿真分析
4、参考论文
略
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~