matlab中的BP神經網絡
MATLAB中一些函數,用于神經網絡
matlab訓練神經網絡,performance圖中的best曲線意思是什么?表示達到最小精度了么?
精度是自己設定的,是那個水平的直線,這里的神經網絡沒有best曲線,就是個goal和training兩條的。是訓練過程中的誤差曲線,表示經過X次訓練,感知器輸出達到目標值,也就是感知器的輸出已經和目標向量一致了。
每一代BP訓練過程的MSE指標的性能,每一代BP交叉驗證過程的MSE指標shu的性能以及BP測試的MSE指標在每一代中執行的過程。 特別是,應該注意內部的TEST紅線,這是BP計算/訓練結果。
擴展資料:
BP(Back Propagation)神經網絡是由Rumelhart和McCelland領導的一組科學家于1986年提出的。BP(Back Propagation)是由反向傳播誤差反向傳播算法訓練的多層前饋網絡,是使用最廣泛的神經網絡模型之一。
BP網絡可以學習并存儲大量的輸入-輸出模式映射關系,而無需事先揭示描述這些映射關系的數學方程式。 BP網絡的學習規則是使用最速下降法,并通過反向傳播來不斷調整網絡的權重和閾值,以最小化網絡的平方誤差之和。 BP神經網絡模型的拓撲包括輸入層,隱藏層和輸出層。
參考資料來源:百度百科-BP神經網絡
matlab神經網絡工具箱訓練出來的函數,怎么輸出得到函數代碼段
這樣:
clear;
%輸入數據矩陣
p1=zeros(1,1000);
p2=zeros(1,1000);
%填充數據
for i=1:1000
p1(i)=rand;
p2(i)=rand;
end
%輸入層有兩個,樣本數為1000
p=[p1;p2];
%目標(輸出)數據矩陣,待擬合的關系為簡單的三角函數
t = cos(pi*p1)+sin(pi*p2);
%對訓練集中的輸入數據矩陣和目標數據矩陣進行歸一化處理
[pn, inputStr] = mapminmax(p);
[tn, outputStr] = mapminmax(t);
%建立BP神經網絡
net = newff(pn, tn, [200,10]);
%每10輪回顯示一次結果
net.trainParam.show = 10;
%最大訓練次數
net.trainParam.epochs = 5000;
%網絡的學習速率
net.trainParam.lr = 0.05;
%訓練網絡所要達到的目標誤差
net.trainParam.goal = 10^(-8);
%網絡誤差如果連續6次迭代都沒變化,則matlab會默認終止訓練。為了讓程序繼續運行,用以下命令取消這條設置
net.divideFcn = '';
%開始訓練網絡
net = train(net, pn, tn);
%訓練完網絡后要求網絡的權值w和閾值b
%獲取網絡權值、閾值
netiw = net.iw;
netlw = net.lw;
netb = net.b;
w1 = net.iw{1,1}; %輸入層到隱層1的權值
b1 = net.b{1} ; %輸入層到隱層1的閾值
w2 = net.lw{2,1}; %隱層1到隱層2的權值
b2 = net.b{2} ; %隱層1到隱層2的閾值
w3 = net.lw{3,2}; %隱層2到輸出層的權值
b3 = net.b{3} ;%隱層2到輸出層的閾值
%在默認的訓練函數下,擬合公式為,y=w3*tansig(w2*tansig(w1*in+b1)+b2)+b3;
%用公式計算測試數據[x1;x2]的輸出,輸入要歸一化,輸出反歸一化
in = mapminmax('apply',[x1;x2],inputStr);
y=w3*tansig(w2*tansig(w1*in+b1)+b2)+b3;
y1=mapminmax('rever',y,outputStr);
%用bp神經網絡驗證計算結果
out = sim(net,in);
out1=mapminmax('rever',out,outputStr);
擴展資料:注意事項
一、訓練函數
1、traingd
Name:Gradient descent backpropagation (梯度下降反向傳播算法 )
Description:triangd is a network training function that updates weight and bias values according to gradient descent.
2、traingda
Name:Gradient descentwith adaptive learning rate backpropagation(自適應學習率的t梯度下降反向傳播算法)
Description:triangd is a network training function that updates weight and bias values according to gradient descent with adaptive learning rate.it will return a trained net (net) and the trianing record (tr).
3、traingdx (newelm函數默認的訓練函數)
name:Gradient descent with momentum and adaptive learning rate backpropagation(帶動量的梯度下降的自適應學習率的反向傳播算法)
Description:triangdx is a network training function that updates weight and bias values according to gradient descent momentumand an adaptive learning rate.it will return a trained net (net) and the trianing record (tr).
4、trainlm
Name:Levenberg-Marquardtbackpropagation(L-M反向傳播算法)
Description:triangd is a network training function that updates weight and bias values according toLevenberg-Marquardt optimization.it will return a trained net (net) and the trianing record (tr).
注:更多的訓練算法請用matlab的help命令查看。
二、學習函數
1、learngd
Name:Gradient descent weight and bias learning function(梯度下降的權值和閾值學習函數)
Description:learngd is the gradient descentweight and bias learning function, it willreturn theweight change dWand a new learning state.
2、learngdm
Name:Gradient descentwith momentumweight and bias learning function(帶動量的梯度下降的權值和閾值學習函數)
Description:learngd is the gradient descentwith momentumweight and bias learning function, it willreturn the weight change dW and a new learning state.
注:更多的學習函數用matlab的help命令查看。
三、訓練函數與學習函數的區別
函數的輸出是權值和閾值的增量,訓練函數的輸出是訓練好的網絡和訓練記錄,在訓練過程中訓練函數不斷調用學習函數修正權值和閾值,通過檢測設定的訓練步數或性能函數計算出的誤差小于設定誤差,來結束訓練。
或者這么說:訓練函數是全局調整權值和閾值,考慮的是整體誤差的最小。學習函數是局部調整權值和閾值,考慮的是單個神經元誤差的最小。
它的基本思想是學習過程由信號的正向傳播與誤差的反向傳播兩個過程組成。
正向傳播時,輸入樣本從輸入層傳入,經各隱層逐層處理后,傳向輸出層。若輸出層的實際輸出與期望的輸出(教師信號)不符,則轉入誤差的反向傳播階段。
反向傳播時,將輸出以某種形式通過隱層向輸入層逐層反傳,并將誤差分攤給各層的所有單元,從而獲得各層單元的誤差信號,此誤差信號即作為修正各單元權值的依據。
如何利用matlab進行神經網絡預測
本文發布于:2023-02-28 19:39:00,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/167762676467500.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:matlab神經網絡(matlab神經網絡43個案例分析).doc
本文 PDF 下載地址:matlab神經網絡(matlab神經網絡43個案例分析).pdf
| 留言與評論(共有 0 條評論) |