《BP神经网络MATLAB代码.docx》由会员分享,可在线阅读,更多相关《BP神经网络MATLAB代码.docx(2页珍藏版)》请在第一文库网上搜索。
1、BP神经网络MATLAB代码装载mat数据文件,bp神经网络的matlab应用实例,供需要人员参考,数据集可以任意替换!clear allclose all;clc;load data3;bad_input= bad_l (: , 1) 1 ;bad_2(:z1),;bad_3(:,1),;bad_4(:zl)bad_5(:z1);good_input=good_l(:,1)1;good_2(:z1)1;good_4(:z1)1;good_5(:z1) 1 ;good_6(:,1)1;good_7(:z1)1;good_8(:z1) 1 ;good_9(:z1)1;good_10(:zl)go
2、od_ll(:,1) *;mid_input=mid_l(:,1)1;mid_2(:A1),;mid_4(:,1),;mid_5(:z1);bad_output(1:5, :)=repmat(0 0 1z 5,1);good_output(1:10,:)=repmat(1 0 0 z10,1);mid_output(1:4,:)=repmat(0 1Input=bad_input;good_input;mid_input;Output=bad_output;good_output;mid_output;input_train = Inputoutput_train = Output(:,:)1
3、;input_test = Input (1:end, :) 1 ;output_test = Output(1:endz :) 1;inputn,inputps=mapminmax(input train);outputn,outputps=mapminmax(output_train);inputn_test=mapminmax(1 apply,input_testz inputps);net=newff(inputn,outputn,10);net.trainParam.epochs=1000;nettrainParam.lr=0.05;nettrainParam.goal=0.0000
4、001;net=train (net,inputn,outputn);inputn_test=mapminmax(1 apply1,input_test,inputps);an=sim(net,inputn_test);test_simu=abs(mapminmax(1 reverse,an,outputps) 1;for i=l:size(test_simu,1)for j=l:3if test_simu(i,j)=max(test_simu(i,:);test_simu(i,j)=0;elsetest_simu(i,j)=1;endendenddisp(1 Real output: 1)output_test1disp (1 Recognition results 1)test_simu