導航:首頁 > 五金知識 > matlab的神經網路工具箱入門

matlab的神經網路工具箱入門

發布時間:2024-12-18 17:34:38

A. matlab神經網路工具箱分別怎麼用

1單擊Apps,在搜索框中輸入neu,下方出現了所有神經網路工具箱。neural net fitting 是我們要使用的神經網路擬合工具箱。 2 在下界面中點擊next 3 單擊load example data set,得到我們需要的測試數據。

B. 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('reverse',y,outputStr);

%用bp神經網路驗證計算結果

out = sim(net,in);

out1=mapminmax('reverse',out,outputStr);

(2)matlab的神經網路工具箱入門擴展閱讀:

注意事項

一、訓練函數

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的神經網路工具箱入門相關的資料

熱點內容
任天堂旗下的設備都有哪些ps3 瀏覽:115
活動矯治器固定裝置的製作實驗報告 瀏覽:278
15平方用什麼製冷 瀏覽:411
廚房下水道閥門怎麼卸 瀏覽:106
蘋果位置怎麼添加設備 瀏覽:620
小虎工具箱第4 瀏覽:721
冒險島機械裝置的蝸牛任務 瀏覽:234
良工閥門怎麼樣有幾個良工 瀏覽:564
我和我的祖國親手設計升旗裝置的工程師是 瀏覽:803
boss是什麼運動器材 瀏覽:628
設計檢測肺活量的裝置 瀏覽:869
美甲儀器怎麼拆 瀏覽:922
排氣閥門改裝視頻教程6 瀏覽:885
二個軸承用什麼隔開 瀏覽:987
電棒防護器材怎麼樣 瀏覽:690
儀表盤裡面出現故障燈是什麼 瀏覽:975
騰訊視頻共享設備怎麼關閉主設備 瀏覽:110
檢測資質需要什麼儀器 瀏覽:447
沸水浴用什麼器材 瀏覽:607
原油減壓蒸餾裝置工藝設計 瀏覽:567