資源描述:
《bp神經(jīng)網(wǎng)絡(luò)預(yù)測的matlab代碼》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、附錄5:BP神經(jīng)網(wǎng)絡(luò)預(yù)測的matlab代碼:P=[00.13860.21970.27730.32190.35840.38920.41590.43940.46050.47960.49700.52780.55450.59910.60890.61820.62710.63560.64380.65160.65920.66640.67350.72220.72750.73270.73780.74270.74750.75220.75680.76130.76570.7700]T=[0.44550.3230.41160.32550.44860.29990.49260.22490.48930.23570.4
2、8660.22490.48190.22170.49970.22690.50270.2170.51550.19180.50580.23950.45410.24080.40540.27010.39420.33160.21970.29630.55760.10610.49560.2670.51260.22380.53140.20830.51910.2080.51330.18480.50890.2420.48120.21290.49270.2870.48320.27420.59690.24030.50560.21730.53640.19940.52780.20150.51640.22390.44
3、890.24040.48690.29630.48980.19870.50750.29170.49430.2902]threshold=[01]net=newff(threshold,[11,2],{'tansig','logsig'},'trainlm');net.trainParam.epochs=6000net.trainParam.goal=0.01LP.lr=0.1;net=train(net,P',T')P_test=[0.77420.77840.78240.78640.79020.7941]out=sim(net,P_test')友情提示:以上面0.7742為例0.7742
4、=ln(47+1)/5因為網(wǎng)絡(luò)輸入有一個元素,對應(yīng)的是測試時間,所以P只有一列,Pi=log(t+1)/10,這樣做的目的是使得這些數(shù)據(jù)的范圍處在[01]區(qū)間之內(nèi),但是事實上對于logsin命令而言輸入?yún)?shù)是正負區(qū)間的任意值,而將輸出值限定于0到1之間。可能只有當輸入值在0到1之間,輸出的函數(shù)才可以通過返歸依化得到正確的對應(yīng)的答案,因此在后面有threshold來限制輸入值的區(qū)間n=-5:0.1:5;a=logsig(n);plot(n,logsig(n))圖像如右圖所示T是指CD4Count*0.02,與HIV分別對應(yīng)的值,是輸出值,有兩組數(shù)據(jù),T的第一列數(shù)據(jù)=表格當中(CD4Cou
5、nt*0.02)÷0.02,再取對數(shù),再÷10T的第一列數(shù)據(jù)=表格當中(HIV)的對數(shù),再÷5這樣就完成了最開始的數(shù)據(jù)導(dǎo)入工作,即為了訓(xùn)練神經(jīng)而進行的輸入與輸出。threshold=[01]---------變量threshold用于規(guī)定輸入向量的最大值和最小值,最大值為1,最小值為0net=newff(threshold,[11,2],{'tansig','logsig'},'trainlm');網(wǎng)絡(luò)中間層神經(jīng)元函數(shù)采用S型正切函數(shù)tansig,設(shè)定網(wǎng)絡(luò)的訓(xùn)練函數(shù)為trainlm,它采用Levenberg-Marquardt算法進行網(wǎng)絡(luò)學習。輸出層神經(jīng)元函數(shù)采用S型對數(shù)函數(shù)logsi
6、gnet.trainParam.epochs=6000net.trainParam.goal=0.01LP.lr=0.1;經(jīng)多次嘗試,當模型的訓(xùn)練次數(shù)取6000,訓(xùn)練目標為0.01,學習速率為0.1,中間神經(jīng)元個數(shù)取11時誤差最?。ㄏ聢D為訓(xùn)練誤差曲線)怎樣看數(shù)據(jù)的誤差?難道只能通過看圖像的方法?.參考資料