-
大小: 11.88MB文件類型: .zip金幣: 2下載: 5 次發(fā)布日期: 2023-06-19
- 語言: Matlab
- 標簽: matlab??神經(jīng)網(wǎng)絡(luò)??
資源簡介
里面包含了MATLAB實例代碼以及相關(guān)數(shù)據(jù),適合做神經(jīng)網(wǎng)絡(luò)的參考
代碼片段和文件信息
%%?Matlab神經(jīng)網(wǎng)絡(luò)43個案例分析
%?基于Elman神經(jīng)網(wǎng)絡(luò)的電力負荷預(yù)測模型研究
%?by?王小川(@王小川_matlab)
%?http://www.matlabsky.com
%?Email:sina363@163.com
%?http://weibo.com/hgsz2003
%%?清空環(huán)境變量
clc;
clear?all
close?all
nntwarn?off;
%%?數(shù)據(jù)載入
load?data;
a=data;
%%?選取訓(xùn)練數(shù)據(jù)和測試數(shù)據(jù)
for?i=1:6
????p(i:)=[a(i:)a(i+1:)a(i+2:)];
end
%?訓(xùn)練數(shù)據(jù)輸入
p_train=p(1:5:);
%?訓(xùn)練數(shù)據(jù)輸出
t_train=a(4:8:);
%?測試數(shù)據(jù)輸入
p_test=p(6:);
%?測試數(shù)據(jù)輸出
t_test=a(9:);
%?為適應(yīng)網(wǎng)絡(luò)結(jié)構(gòu)?做轉(zhuǎn)置
p_train=p_train‘;
t_train=t_train‘;
p_test=p_test‘;
%%?網(wǎng)絡(luò)的建立和訓(xùn)練
%?利用循環(huán),設(shè)置不同的隱藏層神經(jīng)元個數(shù)
nn=[7?11?14?18];
for?i=1:4
????threshold=[0?1;0?1;0?1;0?1;0?1;0?1;0?1;0?1;0?1];
????%?建立Elman神經(jīng)網(wǎng)絡(luò)?隱藏層為nn(i)個神經(jīng)元
????net=newelm(threshold[nn(i)3]{‘tansig‘‘purelin‘});
????%?設(shè)置網(wǎng)絡(luò)訓(xùn)練參數(shù)
????net.trainparam.epochs=1000;
????net.trainparam.show=20;
????%?初始化網(wǎng)絡(luò)
????net=init(net);
????%?Elman網(wǎng)絡(luò)訓(xùn)練
????net=train(netp_traint_train);
????%?預(yù)測數(shù)據(jù)
????y=sim(netp_test);
????%?計算誤差
????error(i:)=y‘-t_test;
end
%%?通過作圖?觀察不同隱藏層神經(jīng)元個數(shù)時,網(wǎng)絡(luò)的預(yù)測效果
plot(1:1:3error(1:)‘-ro‘‘linewidth‘2);
hold?on;
plot(1:1:3error(2:)‘b:x‘‘linewidth‘2);
hold?on;
plot(1:1:3error(3:)‘k-.s‘‘linewidth‘2);
hold?on;
plot(1:1:3error(4:)‘c--d‘‘linewidth‘2);
title(‘Elman預(yù)測誤差圖‘)
set(gca‘Xtick‘[1:3])
legend(‘7‘‘11‘‘14‘‘18‘‘location‘‘best‘)
xlabel(‘時間點‘)
ylabel(‘誤差‘)
hold?off;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6159??2013-08-21?07:25??chapter1\BPDLX.m
?????文件???????3896??2013-08-21?07:15??chapter1\chapter1_1.asv
?????文件???????4030??2013-08-21?07:18??chapter1\chapter1_1.m
?????文件??????93015??2009-08-29?16:54??chapter1\data1.mat
?????文件??????92845??2009-08-29?16:54??chapter1\data2.mat
?????文件??????92937??2009-08-29?16:54??chapter1\data3.mat
?????文件??????93438??2009-08-29?16:54??chapter1\data4.mat
?????目錄??????????0??2013-08-21?07:51??chapter1
-----------?---------??----------?-----??----
???????????????386320????????????????????8
評論
共有 條評論