資源簡介
儲備池應(yīng)用,預(yù)測Mackey_Glass混沌,初步了解儲備池計算。

代碼片段和文件信息
%?A?minimalistic?Echo?State?Networks?demo?with?Mackey-Glass?(delay?17)?data?%?in?“plain“?Matlab.?%?by?Mantas?Lukosevicius?2012?%?http://minds.jacobs-university.de/mantas?%?load?the?data?
function?Mackey_Glass_Reservoircomputing
trainLen?=?2000;?%訓(xùn)練數(shù)據(jù)長2000
testLen?=?2000;?%測試長度2000
initLen?=?100;?%初始化儲備池
data?=?load(‘MackeyGlass_t17.txt‘);%?plot?some?of?it?
figure(10);?
plot(data(1:10000));?????%繪制前1000個數(shù)據(jù)
title(‘A?sample?of?data‘);?%?generate?the?ESN?reservoir??
inSize?=1;
outSize?=??1;?%輸入維數(shù)?
resSize?=?1000;?%儲備池規(guī)模
a?=?0.3;?%?leaking?rate??更新速率,也可設(shè)為1
rand(?‘seed‘?42?);???????
%隨機生成Win?和?W
Win?=?(rand(resSize1+inSize)-0.5)?.*?1;??%輸入矩陣N*1+K
W?=?rand(resSizeresSize)-0.5;%儲備池連接矩陣N*N
??????????????????????????????%?Option?1?-?direct?scaling?(quick&dirty?reservoir-specific):?%?
W?=?W?.*?0.13;?%?Option?2?-?normalizing?and?setting?spectral?radius?(correct?slower):?
disp?‘Computing?spectral?radius...‘;??%計算譜半徑
opt.disp?=?0;?
rhoW?=?abs(eigs(W1‘LM‘opt));?
disp?‘done.‘?
W?=?W?.*?(?1.25?/rhoW);?%?allocated?memory?for?the?design?(collected?states)?matrix?
X?=?zeros(1+inSize+resSizetrainLen-initLen);?%儲備池狀態(tài)矩陣x(t),每一列是每個時刻的儲備池狀態(tài),后面會轉(zhuǎn)置?set?the?corresponding?target?matrix?directly?
Yt?=?data(initLen+2:trainLen+1)‘;?%?run?the?reservoir?with?the?data?and?collect?X?
x?=?zeros(resSize1);?
for?t?=?1:trainLen?
u?=?data(t);?
x?=?(1-a)*x?+?a*tanh(?Win*[1;u]?+?W*x?);?
if?t?>?initLen?X(:t-initLen)?=?[1;u;x];?
end?
end?%?train?the?output?
reg?=?1e-8;?%?regularization?coefficient?
X_T?=?X‘;?
Wout?=?Yt*X_T?*?inv(X*X_T?+?reg*eye(1+inSize+resSize));?%?
Wout?=?Yt*pinv(X);?%?run?the?trained?ESN?in?a?generative?mode.?no?need?to?initialize?here?%?because?x?is?initialized?with?training?data?and?we?continue?from?there.?
Y?=?zeros(outSizetestLen);?
u?=?data(trainLen+1);?
for?t?=?1:testLen?x?=?(1-a)*x?+?a*tanh(?Win*[1;u]?+?W*x?);?
y?=?Wout*[1;u;x];?
Y(:t)?=?y;?%?generative?mode:?
u?=?y;?%?this?would?be?a?predictive?mode:?%
u?=?data(trainLen+t+1);?
end?
errorLen?=?500;?
mse?=?sum((data(trainLen+2:trainLen+errorLen+1)‘-Y(11:errorLen)).^2)./errorLen;?
disp(?[‘MSE?=?‘?num2str(?mse?)]?);?%?plot?some?signals?
figure(1);?
plot(?data(trainLen+2:trainLen+testLen+1)?‘color‘?[00.750]?);?
hold?on;?
plot(?Y‘?‘b‘?);?
hold?off;?
axis?tight;?
title(‘Target?and?generated?signals?y(n)?starting?at?n=0‘);?
legend(‘Target?signal‘?‘Free-running?predicted?signal‘);?
figure(2);?
plot(?X(1:201:200)‘?);?
title(‘Some?reservoir?activations?x(n)‘);?
figure(3);?
bar(?Wout‘?)?
title(‘Output?weights?W^{out}‘);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????265427??2017-12-20?09:30??Mackey_Glass_Reservoircomputing\MackeyGlass_t17.txt
?????文件???????2662??2018-03-29?16:34??Mackey_Glass_Reservoircomputing\Mackey_Glass_Reservoircomputing.m
?????目錄??????????0??2018-09-13?10:01??Mackey_Glass_Reservoircomputing
-----------?---------??----------?-----??----
???????????????268089????????????????????3
- 上一篇:opendaylight入門教程
- 下一篇:freeglut-3.2.1.rar
評論
共有 條評論