matlab卷积完为什么要归一化,为什么要进行反归一化处理,而且反归一化什么意思?...
歸一化處理我理解,但是很多例子的反歸一化我就不是很明白 。如下面這個例子:
%準(zhǔn)備好訓(xùn)練集
%人數(shù)(單位:萬人)
numberOfPeople=[20.55 22.44 25.37 27.13 29.45 30.10 30.96 34.06 36.42 38.09 39.13 39.99 41.93 44.59 47.30 52.89 55.73 56.76 59.17 60.63];
%機動車數(shù)(單位:萬輛)
numberOfAutomobile=[0.6 0.75 0.85 0.9 1.05 1.35 1.45 1.6 1.7 1.85 2.15 2.2 2.25 2.35 2.5 2.6 2.7 2.85 2.95 3.1];
%公路面積(單位:萬平方公里)
roadArea=[0.09 0.11 0.11 0.14 0.20 0.23 0.23 0.32 0.32 0.34 0.36 0.36 0.38 0.49 0.56 0.59 0.59 0.67 0.69 0.79];
%公路客運量(單位:萬人)
passengerVolume = [5126 6217 7730 9145 10460 11387 12353 15750 18304 19836 21024 19490 20433 22598 25107 33442 36836 40548 42927 43462];
%公路貨運量(單位:萬噸)
freightVolume = [1237 1379 1385 1399 1663 1714 1834 4322 8132 8936 11099 11203 10524 11115 13320 16762 18673 20724 20803 21804];
%輸入數(shù)據(jù)矩陣
p = [numberOfPeople; numberOfAutomobile; roadArea];
%目標(biāo)(輸出)數(shù)據(jù)矩陣
t = [passengerVolume; freightVolume];
%對訓(xùn)練集中的輸入數(shù)據(jù)矩陣和目標(biāo)數(shù)據(jù)矩陣進行歸一化處理
[pn, inputStr] = mapminmax(p);
[tn, outputStr] = mapminmax(t);
%建立BP神經(jīng)網(wǎng)絡(luò)
net = newff(pn, tn, [3 7 2], {'purelin', 'logsig', 'purelin'});
%每10輪回顯示一次結(jié)果
net.trainParam.show = 10;
%最大訓(xùn)練次數(shù)
net.trainParam.epochs = 5000;
%網(wǎng)絡(luò)的學(xué)習(xí)速率
net.trainParam.lr = 0.05;
%訓(xùn)練網(wǎng)絡(luò)所要達到的目標(biāo)誤差
net.trainParam.goal = 0.65 * 10^(-3);
%網(wǎng)絡(luò)誤差如果連續(xù)6次迭代都沒變化,則matlab會默認(rèn)終止訓(xùn)練。為了讓程序繼續(xù)運行,用以下命令取消這條設(shè)置
net.divideFcn = '';
%開始訓(xùn)練網(wǎng)絡(luò)
net = train(net, pn, tn);
%使用訓(xùn)練好的網(wǎng)絡(luò),基于訓(xùn)練集的數(shù)據(jù)對BP網(wǎng)絡(luò)進行仿真得到網(wǎng)絡(luò)輸出結(jié)果
%(因為輸入樣本(訓(xùn)練集)容量較少,否則一般必須用新鮮數(shù)據(jù)進行仿真測試)
answer = sim(net, pn);
%反歸一化
answer1 = mapminmax('reverse', answer, outputStr);
%繪制測試樣本神經(jīng)網(wǎng)絡(luò)輸出和實際樣本輸出的對比圖(figure(1))-------------------------------------------
t = 1990:2009;
%測試樣本網(wǎng)絡(luò)輸出客運量
a1 = answer1(1,:);
%測試樣本網(wǎng)絡(luò)輸出貨運量
a2 = answer1(2,:);
figure(1);
subplot(2, 1, 1); plot(t, a1, 'ro', t, passengerVolume, 'b+');
legend('網(wǎng)絡(luò)輸出客運量', '實際客運量');
xlabel('年份'); ylabel('客運量/萬人');
title('神經(jīng)網(wǎng)絡(luò)客運量學(xué)習(xí)與測試對比圖');
grid on;
subplot(2, 1, 2); plot(t, a2, 'ro', t, freightVolume, 'b+');
legend('網(wǎng)絡(luò)輸出貨運量', '實際貨運量');
xlabel('年份'); ylabel('貨運量/萬噸');
title('神經(jīng)網(wǎng)絡(luò)貨運量學(xué)習(xí)與測試對比圖');
grid on;
%使用訓(xùn)練好的神經(jīng)網(wǎng)絡(luò)對新輸入數(shù)據(jù)進行預(yù)測
%新輸入數(shù)據(jù)(2010年和2011年的相關(guān)數(shù)據(jù))
newInput = [73.39 75.55; 3.9635 4.0975; 0.9880 1.0268];
%利用原始輸入數(shù)據(jù)(訓(xùn)練集的輸入數(shù)據(jù))的歸一化參數(shù)對新輸入數(shù)據(jù)進行歸一化
newInput = mapminmax('apply', newInput, inputStr);
%進行仿真
newOutput = sim(net, newInput);
%反歸一化
newOutput = mapminmax('reverse',newOutput, outputStr);
disp('預(yù)測2010和2011年的公路客運量分別為(單位:萬人):');
newOutput(1,:)
disp('預(yù)測2010和2011年的公路貨運量分別為(單位:萬噸):');
newOutput(2,:)
%在figure(1)的基礎(chǔ)上繪制2010和2011年的預(yù)測情況-------------------------------------------------------
figure(2);
t1 = 1990:2011;
subplot(2, 1, 1); plot(t1, [a1 newOutput(1,:)], 'ro', t, passengerVolume, 'b+');
legend('網(wǎng)絡(luò)輸出客運量', '實際客運量');
xlabel('年份'); ylabel('客運量/萬人');
title('神經(jīng)網(wǎng)絡(luò)客運量學(xué)習(xí)與測試對比圖(添加了預(yù)測數(shù)據(jù))');
grid on;
subplot(2, 1, 2); plot(t1, [a2 newOutput(2,:)], 'ro', t, freightVolume, 'b+');
legend('網(wǎng)絡(luò)輸出貨運量', '實際貨運量');
xlabel('年份'); ylabel('貨運量/萬噸');
title('神經(jīng)網(wǎng)絡(luò)貨運量學(xué)習(xí)與測試對比圖(添加了預(yù)測數(shù)據(jù))');
grid on;
預(yù)測的時候反歸一化為啥呀
總結(jié)
以上是生活随笔為你收集整理的matlab卷积完为什么要归一化,为什么要进行反归一化处理,而且反归一化什么意思?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python tesseract ocr
- 下一篇: matlab人脸追踪,求大神帮助我这个菜