資源簡介
完整的Elman神經(jīng)網(wǎng)絡(luò)預(yù)測模型,包含相關(guān)的數(shù)據(jù) 可在matlab2016a中運(yùn)行。

代碼片段和文件信息
%%??案例18:?基于Elman神經(jīng)網(wǎng)絡(luò)的電力負(fù)荷預(yù)測模型研究
%?
%?
%?
%? 該案例作者申明: 1:本人長期駐扎在此板塊里,對該案例提問,做到有問必答。 2:此案例有配套的教學(xué)視頻,配套的完整可運(yùn)行Matlab程序。 3:以下內(nèi)容為該案例的部分內(nèi)容(約占該案例完整內(nèi)容的1/10)。 4:此案例為原創(chuàng)案例,轉(zhuǎn)載請注明出處(Matlab中文論壇,《Matlab神經(jīng)網(wǎng)絡(luò)30個案例分析》)。 5:若此案例碰巧與您的研究有關(guān)聯(lián),我們歡迎您提意見,要求等,我們考慮后可以加在案例里。 6:您看到的以下內(nèi)容為初稿,書籍的實際內(nèi)容可能有少許出入,以書籍實際發(fā)行內(nèi)容為準(zhǔn)。 7:此書其他常見問題、預(yù)定方式等,請點(diǎn)擊這里。
%?
%?
%%?清空環(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(‘時間點(diǎn)‘)
ylabel(‘誤差‘)
hold?off;
web?browser?http://www.ilovematlab.cn/viewthread.php?tid=63640
%%
%
%?
%? 版權(quán)所有:%?href=“http://www.ilovematlab.cn/“>Matlab中文論壇 ?ript
%?src=“http://s3.cnzz.com/stat.php?id=971931&web_id=971931&show=pic“?language=“javascript“?> ript>
%?
%
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3258??2018-12-26?14:05??Elman神經(jīng)網(wǎng)絡(luò)預(yù)測模型研究\chapter18.m
?????文件?????????406??2018-12-26?14:05??Elman神經(jīng)網(wǎng)絡(luò)預(yù)測模型研究\data.mat
?????目錄???????????0??2019-04-18?15:21??Elman神經(jīng)網(wǎng)絡(luò)預(yù)測模型研究\
評論
共有 條評論