新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法_第1頁
新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法_第2頁
新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法_第3頁
新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法_第4頁
新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、新版Matlab中神經(jīng)網(wǎng)絡(luò)訓(xùn)練函數(shù)Newff的使用方法一、 介紹新版newffSyntax· net = newff(P,T,S1 S2.S(N-l),TF1 TF2.TFNl, BTF,BLF,PF,IPF,OPF,DDF)Descriptionnewff(P,T,S1 S2.S(N-l),TF1 TF2.TFNl, BTF,BLF,PF,IPF,OPF,DDF) takes several argumentsPR x Q1 matrix of Q1 sample R-element input vectorsTSN x Q2 matrix of Q2 sample SN-elem

2、ent target vectorsSiSize of ith layer, for N-1 layers, default = .(Output layer size SN is determined from T.)TFiTransfer function of ith layer. (Default = 'tansig' forhidden layers and 'purelin' for output layer.)BTFBackpropagation network training function (default = 'trainlm&#

3、39;)BLFBackpropagation weight/bias learning function (default = 'learngdm')IPFRow cell array of input processing functions. (Default = 'fixunknowns','removeconstantrows','mapminmax')OPFRow cell array of output processing functions. (Default = 'removeconstantrows&#

4、39;,'mapminmax')DDFData divison function (default = 'dividerand')ExamplesHere is a problem consisting of inputs P and targets T to be solved with a network.· P = 0 1 2 3 4 5 6 7 8 9 10;T = 0 1 2 3 4 3 2 1 2 3 4;Here a network is created with one hidden layer of five neurons.

5、3; net = newff(P,T,5);The network is simulated and its output plotted against the targets.· Y = sim(net,P);plot(P,T,P,Y,'o')The network is trained for 50 epochs. Again the network's output is plotted.· net.trainParam.epochs = 50;net = train(net,P,T);Y = sim(net,P);plot(P,T,P,Y,

6、'o')二、 新版newff與舊版newff調(diào)用語法對比Example1比如輸入input(6*1000),輸出output為(4*1000),那么舊版定義:net=newff(minmax(input),14,4,'tansig','purelin','trainlm');新版定義:net=newff(input,output,14,'tansig','purelin','trainlm');Example2比如輸入input(6*1000),輸出output為(4*1000),那

7、么舊版定義:net=newff(minmax(input),49,14,4,'tansig','tansig','tansig','traingdx');新版定義:net=newff(input,output, 49,14, 'tansig','tansig','tansig','traingdx');三、 舊版newff使用方法在新版本中使用提示:舊版本定義的newff雖也能在新版本中使用,但會有警告,警告如下:Warning: NEWFF used in an o

8、bsolete way. > In obs_use at 18  In newff>create_network at 127  In newff at 102          See help for NEWFF to update calls to the new argument list.四、 新版newff與舊版newff使用的訓(xùn)練效果對比舊版本:舊用法訓(xùn)練次數(shù)多,但精度高 新版本:新用法訓(xùn)練次數(shù)少,但精度可能達(dá)不到要求造成上述原因是:程序里面的權(quán)值、閾值的初始值是隨機(jī)賦

9、值的,所以每次運(yùn)行的結(jié)果都會不一樣,有好有壞。你可以把預(yù)測效果不錯的網(wǎng)絡(luò)的權(quán)值和閾值作為初始值。具體可以查看net.iw1,1、net.lw2,1、net.b1、net.b2的值?,F(xiàn)在給一個完整的例子 % 清空環(huán)境變量clcclear% 訓(xùn)練數(shù)據(jù)預(yù)測數(shù)據(jù)data=importdata('test.txt');%從1到768間隨機(jī)排序k=rand(1,768);m,n=sort(k);%輸入輸出數(shù)據(jù)input=data(:,1:8);output =data(:,9);%隨機(jī)提取500個樣本為訓(xùn)練樣本,268個樣本為預(yù)測樣本input_train=input(n(1:500),:

10、)'output_train=output(n(1:500),:)'input_test=input(n(501:768),:)'output_test=output(n(501:768),:)'%輸入數(shù)據(jù)歸一化inputn,inputps=mapminmax(input_train);% BP網(wǎng)絡(luò)訓(xùn)練% %初始化網(wǎng)絡(luò)結(jié)構(gòu)net=newff(inputn,output_train,10);net.trainParam.epochs=1000;net.trainParam.lr=0.1;net.trainParam.goal=0.0000004;% 網(wǎng)絡(luò)訓(xùn)練net

11、=train(net,inputn,output_train);% BP網(wǎng)絡(luò)預(yù)測%預(yù)測數(shù)據(jù)歸一化inputn_test=mapminmax('apply',input_test,inputps);%網(wǎng)絡(luò)預(yù)測輸出BPoutput=sim(net,inputn_test);% 結(jié)果分析%根據(jù)網(wǎng)絡(luò)輸出找出數(shù)據(jù)屬于哪類BPoutput(find(BPoutput<0.5)=0;BPoutput(find(BPoutput>=0.5)=1;% 結(jié)果分析%畫出預(yù)測種類和實際種類的分類圖figure(1)plot(BPoutput,'og')hold onplot(output_test,'r*');legend('預(yù)測類別','輸出類別')title('BP網(wǎng)絡(luò)預(yù)測分類與實際類別比對','fontsize',12)ylabel('類別標(biāo)簽','fontsize',12)xlabel('樣本數(shù)目','fontsize',12)ylim(-0.5 1.5)%預(yù)測正確率rightnum

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論