赞
踩
function C_net_BP01 u_hebing=textread('u_hebing.txt'); f_hebing=textread('f_hebing.txt'); %数据验证=============================================================== data16test=textread('val_in_03_all_fifth.txt','%s'); data16to2test=hex2dec(data16test)'; Changdu16to2test=length(data16to2test); lietest=Changdu16to2test/6; grouptest=zeros(lietest,6); for itest=1:lietest grouptest(itest,:)=data16to2test(6*itest-5:6*itest); end data_read0test=textread('standard_reading_03_all_fifth.txt'); jiequ_n=96;jiequ_m=121;%截取行数96-121比较匹配 u_jiequ=grouptest(jiequ_n:jiequ_m,:); f_jiequ=data_read0test(jiequ_n:jiequ_m,1:6); for iitest=1:(jiequ_m-jiequ_n+1)/2 u_chazhitest(iitest,:)=u_jiequ(2*iitest,:)-u_jiequ(2*iitest-1,:); f_chazhitest(iitest,:)=f_jiequ(2*iitest,:)-f_jiequ(2*iitest-1,:); end % 归一化处理============================================== [u_guiyi,u_guiyi_ps]=mapminmax(u_hebing.'); [f_guiyi,f_guiyi_ps]=mapminmax(f_hebing.'); u_guiyi_test=mapminmax('apply',u_chazhitest.',u_guiyi_ps); f_guiyi_test=mapminmax('apply',f_chazhitest.',f_guiyi_ps); %训练BP神经网络========================================================= net=feedforwardnet(3,'trainlm'); view(net) net=train(net,u_hebing.',f_hebing.'); view(net) f_wucha=net(u_hebing.'); perf=perform(net,f_wucha,f_hebing.') save 'C_net_BP01' net %带入BP神经网络 f_out=sim(net,u_chazhitest.').'; %网络权值阈值矩阵======================================================= b1=net.b{1}; iw=net.iw{1,1}; b2=net.b{2}; lw=net.lw{2,1}; %离线神经网络表达式 f_offline_guiyi=(purelin(lw*tansig(iw*u_guiyi_test+b1)+b2)); f_offline=mapminmax('reverse',f_offline_guiyi,f_guiyi_ps).'; end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。