Anda di halaman 1dari 16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
From:GregHeath
Date:16Apr,201604:57:03
Message:1of5
Replytothismessage
RemoveauthorfromMyWatchList
Vieworiginalformat
Flagasspam
Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
NOINPUT/POSTTARGETMULTISTEPTIMESERIESPREDICTION(NARNET)
Reference:http://www.mathworks.com/matlabcentral/newsreader/...
view_thread/338508#945325
1.Idon'trecommendusingntstoolforcomplicatedproblemsuntilyouaremoreexperienced.Thecommandlinescriptitgeneratesofferssomanyoptionsthatit
obscuresthemostimportantchoices.Thealternativeistofirstusetheabbreviatedscriptsinthehelpanddocdocumentationthattakeadvantageofdefault
optionsanduseMATLABexampledatathatcanbeobtainedfromthehelpanddoccommands

helpnndatasets
docnndatasets

Thiswillnotonlyprepareyoubetterwithbasics,itwillmakeiteasierforusto
helpifyouhavedifficulties.

2.Whenyouonlyhaveoneseries,theappropriatefunctiontouseisNARNET.Firstobtainandcomparethedocumentationandsimplecodeexamplesobtained
fromthecommands

helpnarnet
docnarnet

Second,noticethatdifferentnotationisused.Ipreferthenotationindocnarnetbecauseitdoesnotuselowercaseforcellvariables.However,insteadofusing
the"s"subscripttoindicatevariablesusedintheopenloop"s"eries.Iprefertousethemoreobviousnotations"o"andOLforopenloopalongwith"c"andCLfor
closedloop.

Third,theexplanationindocERRONEOUSLYstatesthat0isanallowable
outputfeedbackdelay.ITISNOT!Inparticular:

ItisonlyallowableintheOLconfigurationbecausetheprogramconsidersitasanexternalinput.However,itisnotallowableintheCLconfiguration.So,Iseeno
goodreasonforusingit.

3.TheexamplesusethedefaultdatadivisonoptionDIVIDERANDwhichcreatesrandomnonuniformtimestepswithinthetraining,validationandtestsubsets.
Thisisgreatforregressionandclassification.Fortimeseriesprediction,however,itcanbeDISASTEROUS!

Thereareavarietyofwaystoobtainuniformtimestepswithinthesubsetsusingotherdatadivisionoptions.IfavorDIVIDEBLOCKwhichyieldstheindexing

[1:Ntrn,Ntrn+1:Ntrn+Nval,Ntrn+Nval+1:N]

whereN=Ntrn+Nval+Ntst.Thedefaultpercentagesare0.7/0.15/0.15.

4.Theexampleindocyieldsascaledependentvaluefortheperformance
whichisrepeatableonlyiftheinitialstateoftherandomnumbergeneratoris
known.

5.Ipreferthefollowingversionthat
(a)Explicitlyshows
i.Thesizeoftheinputandtargetmatrices
ii.Theminandmaxvaluesofinputandtarget
iii.Thecorrespondingminandmaxvaluesofthestandardized
(i.e.,zeromean/unitvariance)valuesforoutlierdetection
iv.Theaveragetargetvariancethatwillbeusedasthereference
meansquareerror
(b)ShowsthemostgeneralformofthesyntaxontheLHSoftrainingand
outputequations.However,somemaynotbevalidforversionsolder
thanR2014a.

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

1/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

(c)Specifiestheinitialrandomnumberstatesothattheexamplecanbe
duplicatedexactly
(d)Usesascaleindependentnormalizationforthemeansquareerror
performancevaluethatindicatesthefractionofthetargetvariancethatis
notmodelledbythenet.
6.Beforeusingyourowndata,itisSTRONGLYRECOMMENDEDtopractice
onMATLABexampledataobtainedfrom

helpnndatasets
docnndatasets
Thatwillmakeiteasierforustohelpifyouhaveproblems.
7.Finally,theexamplebelowassumesthatthedefaultfeedbackdelay(FD)andnumberofhiddennode(H)parametersaresufficient.Ingeneral,theywillnotbe.
Myapproachtothisdifficultyis
a.ChooseFDfromasubsetofthedelayscorrespondingtostatistically
significantvaluesofthetargetautocorrelationfunction(e.g.,NNCORR).
b.GivenatrialvalueofFD,useadoubleforloopsearch
forh=Hmin:dH:Hmax%Numberofhiddennodes
...
fori=1:Ntrials%Randominitialweights
...
end
end
c.ManyexamplesofthisapproachhavebeenpostedintheNEWSGROUP
andANSWERS.IncludethenameofthecorrelationfunctionNNCORRas
asearchword.
closeall,clearall,clc,plt=0
T=simplenar_dataset
[IN]=size(T)%[1100]
d=2,FD=1:dH=10%MATLABdefaults
neto=narnet(FD,H)
neto.divideFcn='divideblock'
view(neto)
[Xo,Xoi,Aoi,To]=preparets(neto,{},{},T)
to=cell2mat(To)zto=zscore(to,1)
varto1=mean(var(to',1))%0.061307
minmaxto=minmax([tozto])
%minmaxto=0.239110.99991
%1.97631.0963
%Nooutliers
plt=plt+1figure(plt),holdon
plot(d+1:N,to,'LineWidth',2)
rng('default')
[netotroYoEoAofXof]=train(neto,Xo,To,Xoi,Aoi)
[YoXofAof]=net(Xo,Xoi,Aoi)
Eo=gsubtract(To,Yo)
view(neto)
NMSEo=mse(Eo)/varto1%6.6721e09
%tro=tro%Nosemicolon.RevealstheOLtrainingrecord
yo=cell2mat(Yo)
plot(d+1:N,yo,'ro','LineWidth',2)
axis([010201.3])
legend('TARGET','OUTPUT')
title('OPENLOOPNARNETRESULTS')
7.Now,theoutputfeedbackloopisclosedandtestedsothatpredictionscan
eventuallybeextendedbeyondthetimeoftheknowntarget,T.
[netcXciAci]=closeloop(neto,Xoi,Aoi)
view(netc)
[Xc,Xci,Aci,Tc]=preparets(netc,{},{},T)
isequal(Tc,To),tc=to%1
[YcXcfAcf]=netc(Xc,Xci,Aci)

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

2/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

Ec=gsubtract(Tc,Yc)
yc=cell2mat(Yc)
NMSEc=mse(Ec)/var(tc,1)%3.2807e07
Althoughtheperformanceisafactorof50worse,itisstillexcellent.Ifitwere
significantlydegraded(e.g.,below~0.005),netcwouldbetrainedstartingwiththeweightsobtainedintheopenloopstage(NOTE:Thisisnotmentionedineither
thehelpordocdocumentation).

8.Theremovedelayfunctionisincludedinbothdocumentations.However,I
seenogoodreasonforusingithere.Forexample,whenusedwiththedefaultoutputfeedbackdelay1:2,ityieldsinvalidzeroand/ornegativevalues.

ISTHISABUGTHATNEEDSTOBEFIXED?

9.Toextendthepredictionbeyondtheendoftheknownseries,emptycellsareusedasinputsandthefinaldelaystatesXcfandAcfareusedasinitial
conditions.

[YcXcfAcf]=netc(Xc,Xci,Aci)
Xc2=cell(1,N)
[Yc2Xcf2Acf2]=netc(Xc2,Xcf,Acf)
yc2=cell2mat(Yc2)

plt=plt+1figure(plt),holdon
plot(d+1:N,tc,'LineWidth',2)
plot(d+1:N,yc,'o','LineWidth',2)
plot(N+1:2*N,yc2,'ro','LineWidth',2)
plot(N+1:2*N,yc2,'r','LineWidth',2)
axis([02*N+201.3])
legend('TARGET','OUTPUT','TARGETLESSPREDICTION')
title('CLOSEDLOOPNARNETRESULTS')
Hopethishelps.
Greg

Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
From:Staffan
Date:29Apr,201617:50:03
Message:2of5
Replytothismessage
AddauthortoMyWatchList
Vieworiginalformat
Flagasspam
"GregHeath"<heath@alumni.brown.edu>wroteinmessage<nesgmv$jo4$1@newscl01ah.mathworks.com>...
>Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
>
>NOINPUT/POSTTARGETMULTISTEPTIMESERIESPREDICTION(NARNET)
>Reference:http://www.mathworks.com/matlabcentral/newsreader/...
>view_thread/338508#945325
>
>1.Idon'trecommendusingntstoolforcomplicatedproblemsuntilyouaremoreexperienced.Thecommandlinescriptitgeneratesofferssomanyoptionsthatit
obscuresthemostimportantchoices.Thealternativeistofirstusetheabbreviatedscriptsinthehelpanddocdocumentationthattakeadvantageofdefault
optionsanduseMATLABexampledatathatcanbeobtainedfromthehelpanddoccommands
>
>helpnndatasets
>docnndatasets
>
>Thiswillnotonlyprepareyoubetterwithbasics,itwillmakeiteasierforusto
>helpifyouhavedifficulties.
>
>2.Whenyouonlyhaveoneseries,theappropriatefunctiontouseisNARNET.Firstobtainandcomparethedocumentationandsimplecodeexamplesobtained
fromthecommands
>
>helpnarnet
>docnarnet
>

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

3/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

>Second,noticethatdifferentnotationisused.Ipreferthenotationindocnarnetbecauseitdoesnotuselowercaseforcellvariables.However,insteadofusing
the"s"subscripttoindicatevariablesusedintheopenloop"s"eries.Iprefertousethemoreobviousnotations"o"andOLforopenloopalongwith"c"andCLfor
closedloop.
>
>Third,theexplanationindocERRONEOUSLYstatesthat0isanallowable
>outputfeedbackdelay.ITISNOT!Inparticular:
>
>ItisonlyallowableintheOLconfigurationbecausetheprogramconsidersitasanexternalinput.However,itisnotallowableintheCLconfiguration.So,Isee
nogoodreasonforusingit.
>
>3.TheexamplesusethedefaultdatadivisonoptionDIVIDERANDwhichcreatesrandomnonuniformtimestepswithinthetraining,validationandtestsubsets.
Thisisgreatforregressionandclassification.Fortimeseriesprediction,however,itcanbeDISASTEROUS!
>
>Thereareavarietyofwaystoobtainuniformtimestepswithinthesubsetsusingotherdatadivisionoptions.IfavorDIVIDEBLOCKwhichyieldstheindexing
>
>[1:Ntrn,Ntrn+1:Ntrn+Nval,Ntrn+Nval+1:N]
>
>whereN=Ntrn+Nval+Ntst.Thedefaultpercentagesare0.7/0.15/0.15.
>
>4.Theexampleindocyieldsascaledependentvaluefortheperformance
>whichisrepeatableonlyiftheinitialstateoftherandomnumbergeneratoris
>known.
>
>5.Ipreferthefollowingversionthat
>(a)Explicitlyshows
>i.Thesizeoftheinputandtargetmatrices
>ii.Theminandmaxvaluesofinputandtarget
>iii.Thecorrespondingminandmaxvaluesofthestandardized
>(i.e.,zeromean/unitvariance)valuesforoutlierdetection
>iv.Theaveragetargetvariancethatwillbeusedasthereference
>meansquareerror
>(b)ShowsthemostgeneralformofthesyntaxontheLHSoftrainingand
>outputequations.However,somemaynotbevalidforversionsolder
>thanR2014a.
>(c)Specifiestheinitialrandomnumberstatesothattheexamplecanbe
>duplicatedexactly
>(d)Usesascaleindependentnormalizationforthemeansquareerror
>performancevaluethatindicatesthefractionofthetargetvariancethatis
>notmodelledbythenet.
>6.Beforeusingyourowndata,itisSTRONGLYRECOMMENDEDtopractice
>onMATLABexampledataobtainedfrom
>
>helpnndatasets
>docnndatasets
>
>Thatwillmakeiteasierforustohelpifyouhaveproblems.
>7.Finally,theexamplebelowassumesthatthedefaultfeedbackdelay(FD)andnumberofhiddennode(H)parametersaresufficient.Ingeneral,theywillnot
be.Myapproachtothisdifficultyis
>a.ChooseFDfromasubsetofthedelayscorrespondingtostatistically
>significantvaluesofthetargetautocorrelationfunction(e.g.,NNCORR).
>b.GivenatrialvalueofFD,useadoubleforloopsearch
>
>forh=Hmin:dH:Hmax%Numberofhiddennodes
>...
>fori=1:Ntrials%Randominitialweights
>...
>end
>end
>c.ManyexamplesofthisapproachhavebeenpostedintheNEWSGROUP
>andANSWERS.IncludethenameofthecorrelationfunctionNNCORRas
>asearchword.
>
>closeall,clearall,clc,plt=0
>T=simplenar_dataset
>[IN]=size(T)%[1100]
>d=2,FD=1:dH=10%MATLABdefaults
>neto=narnet(FD,H)
>neto.divideFcn='divideblock'
>view(neto)

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

4/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

>[Xo,Xoi,Aoi,To]=preparets(neto,{},{},T)
>to=cell2mat(To)zto=zscore(to,1)
>varto1=mean(var(to',1))%0.061307
>minmaxto=minmax([tozto])
>%minmaxto=0.239110.99991
>%1.97631.0963
>%Nooutliers
>
>plt=plt+1figure(plt),holdon
>plot(d+1:N,to,'LineWidth',2)
>
>rng('default')
>[netotroYoEoAofXof]=train(neto,Xo,To,Xoi,Aoi)
>[YoXofAof]=net(Xo,Xoi,Aoi)
>Eo=gsubtract(To,Yo)
>view(neto)
>NMSEo=mse(Eo)/varto1%6.6721e09
>
>%tro=tro%Nosemicolon.RevealstheOLtrainingrecord
>
>yo=cell2mat(Yo)
>plot(d+1:N,yo,'ro','LineWidth',2)
>axis([010201.3])
>legend('TARGET','OUTPUT')
>title('OPENLOOPNARNETRESULTS')
>
>7.Now,theoutputfeedbackloopisclosedandtestedsothatpredictionscan
>eventuallybeextendedbeyondthetimeoftheknowntarget,T.
>
>[netcXciAci]=closeloop(neto,Xoi,Aoi)
>view(netc)
>[Xc,Xci,Aci,Tc]=preparets(netc,{},{},T)
>isequal(Tc,To),tc=to%1
>[YcXcfAcf]=netc(Xc,Xci,Aci)
>Ec=gsubtract(Tc,Yc)
>yc=cell2mat(Yc)
>NMSEc=mse(Ec)/var(tc,1)%3.2807e07
>
>Althoughtheperformanceisafactorof50worse,itisstillexcellent.Ifitwere
>significantlydegraded(e.g.,below~0.005),netcwouldbetrainedstartingwiththeweightsobtainedintheopenloopstage(NOTE:Thisisnotmentionedin
eitherthehelpordocdocumentation).
>
>8.Theremovedelayfunctionisincludedinbothdocumentations.However,I
>seenogoodreasonforusingithere.Forexample,whenusedwiththedefaultoutputfeedbackdelay1:2,ityieldsinvalidzeroand/ornegativevalues.
>
>ISTHISABUGTHATNEEDSTOBEFIXED?
>
>9.Toextendthepredictionbeyondtheendoftheknownseries,emptycellsareusedasinputsandthefinaldelaystatesXcfandAcfareusedasinitial
conditions.
>
>[YcXcfAcf]=netc(Xc,Xci,Aci)
>Xc2=cell(1,N)
>[Yc2Xcf2Acf2]=netc(Xc2,Xcf,Acf)
>yc2=cell2mat(Yc2)
>
>plt=plt+1figure(plt),holdon
>plot(d+1:N,tc,'LineWidth',2)
>plot(d+1:N,yc,'o','LineWidth',2)
>plot(N+1:2*N,yc2,'ro','LineWidth',2)
>plot(N+1:2*N,yc2,'r','LineWidth',2)
>axis([02*N+201.3])
>legend('TARGET','OUTPUT','TARGETLESSPREDICTION')
>title('CLOSEDLOOPNARNETRESULTS')
>
>Hopethishelps.
>
>Greg

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

5/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

HelloGreg,
Thanksforthesummary.UsingyourcodeincombinationwithinformationfromotherthreadsIhaveputtogetheranexampleforpredictingvaluesbasedonthe
solardataset.IselectedtoworkfurtheronthisdatasetbecauseIassumethatthemostcomplexmodelwouldnotbeneeded,thesinodialnatureofthisdataset
makesmethinkthatthisshouldbesimplerandrequirealesscomplexmodelthanwhatwouldberequiredwhenworkingwithotherdatasets.
BelowinthecodeIhavemadesomecommentsandaddedsomequestions,themoreimportantcomments/questionsaresurroundedwith###.
Therearemanypossibleimprovementsutilise,e.g.thenumberofneuronsandthenumberofhiddenlayers,however,Ithoughtthiswouldbeagoodtimetoget
somecommentsonthecodeandtoseeifImheadedintherightdirection(anobviousimprovementwouldbetoincreasethenumberinsiglagbutIvemaxedout
mymemoryselectingthesuggested(>=sigthresh95)amount).
Ittakesawhiletorunthecode,IdonthaveTeslaK40inSLIyetbutthiscouldbeapartofaninterestingfuturedevelopment.

closeall
clearall
clearvars
plt=0
T=solar_dataset
t=cell2mat(T)
[I,N]=size(t)

%###OnethingIthinkofinitiallyistheuseoftrainingalgoritm,
%shouldonealwaysfirstusetrainlminallsteps(OLandCL)oris
%thereascientificapproachthatcandetermine(beforetrainingisstarted)
%ife.g.trainbrwouldfitaspecificsignalbetter?###

MSE00=var(t',1)

zt=zscore(t',1)'
plt=plt+1
figure(plt)
subplot(211)
plot(t)

title('SOLARDATASET')

subplot(212)
plot(zt)
title('SOLARDATASET,STANDARDIZED')

rng('default')

L=floor(0.95*(2*N1))%189
fori=1:100
n=randn(1,N)
autocorrn=nncorr(n,n,N1,'biased')
sortabsautocorrn=sort(abs(autocorrn))
thresh95(i)=sortabsautocorrn(L)
end
sigthresh95=mean(thresh95)%0.2194

autocorrt=nncorr(zt,zt,N1,'biased')
%siglag95=1+find(abs(autocorrt(N:2*N1))>=sigthresh95)
siglag95=1+find(abs(autocorrt(N:2*N1))>=0.25)%###MemoryismaxingoutifIusealllagvaluesfromtheaboveline,probablythisisoneofthemost
importantimprovementareas###

plt=plt+1figure(plt)
holdon
plot(0:N1,sigthresh95*ones(1,N),'b')
plot(0:N1,zeros(1,N),'k')

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

6/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

plot(0:N1,sigthresh95*ones(1,N),'b')
plot(0:N1,autocorrt(N:2*N1))
plot(siglag95,autocorrt(N+siglag95),'ro')
title('REDUCEDNUMBEROFAUTOCORRELATIONSINSOLARDATASET')

best_Y=[]
NMSEin=Inf
i=0

rng('default')%###Shouldthisbeplacedinsideoroutsideofthefor(n)looporthefor(j)loop?Whatdifferencedoesthesethreealternativesgive?###

min_nodes=2
max_nodes=15
trails=10

forn=min_nodes:max_nodes%25%alotofpossibleoptionshere,usingmorethanonehiddenlayerwouldbeinterestingtoinvestigate
i=i+1%Counterforindicesinsidethesecondloop(donottieupanythington).

forj=1:trails
net=narnet(siglag95(2:end),n)

net.divideFcn='divideblock'%Ididnottryrandomizingthesestateshereyet,possiblefutureimprovement...
net.trainParam.max_fail=10
[Xo,Xoi,Aoi,To]=preparets(net,{},{},T)
[net,tr,Yo,Eo,Xof,Aof]=train(net,Xo,To,Xoi,Aoi)
%view(net)
Yo=net(Xo,Xoi,Aoi)
Eo=gsubtract(To,Yo)
NMSEo_temp(i,j)=mse(Eo)/MSE00
%thislooptakeslongtime,ifboredwatchthishttps://www.youtube.com/watch?v=YVwQaQK9yu4
end

NMSEo=mean(NMSEo_temp(i,:))

if(NMSEo<NMSEin)
fprintf('BestNMSEsofar:%4.3f(for%dHiddennodes)\n',NMSEo,n)
NMSEin=NMSEo
best_Y=Yo
N_use=n

end

end
%Twoplotstolookaterrorvs.nodesandtrials

plt=plt+1figure(plt),holdon
plot(min_nodes:max_nodes,mean(NMSEo_temp'))
xlabel('Numberofnodes')
ylabel('NMSEo')
title('CorrelationbetweennumberofnodesandaverageofNMSEo')
holdoff

plt=plt+1figure(plt)
contourf(1:trails,min_nodes:max_nodes,NMSEo_temp)
xlabel('trialnumber')
ylabel('Numberofnodes')
title('Correlationbetweennumberofnodes,trialnumberandaverageofNMSEo')
%addxandylabels

%notetoselfaboveisfromthefile"autocorr_analysis"
%notetoselfbelowisfromthefile"narnet_solar"

FD=siglag95(2:end)
FD_length=length(FD)
d=max(FD)

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

7/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

neto=narnet(FD,N_use)

neto.divideFcn='divideblock'
neto.trainParam.max_fail=10
%view(neto)
[Xo,Xoi,Aoi,To]=preparets(neto,{},{},T)
to=cell2mat(To)
zto=zscore(to,1)
varto1=mean(var(to',1))
minmaxto=minmax([tozto])%Isusedtocheckforoutliers,ifoutliersaredetectedthisshouldbeevaluatedatanearlierstage
plt=plt+1figure(plt),holdon
plot(d+1:N,to)%,'LineWidth',2)
rng('default')
[neto,tro,Yo,Eo,Aof,Xof]=train(neto,Xo,To,Xoi,Aoi)
[Yo,Xof,Aof]=neto(Xo,Xoi,Aoi)%[Yo,Xof,Aof]=net(Xo,Xoi,Aoi)Error?
Eo=gsubtract(To,Yo)
%view(neto)
NMSEo=mse(Eo)/varto1
%tro=tro%Nosemicolon.RevealstheOLtrainingrecord
yo=cell2mat(Yo)
plot(d+1:N,yo,'g')%,'ro','LineWidth',2)
%axis([010201.3])
legend('TARGET','OUTPUT')
title('OPENLOOPNARNETRESULTS')

netc=closeloop(neto)%[netc,Xci,Aci]=closeloop(neto,Xoi,Aoi)ErrorornotcompatiblewithR2012b?
netc.divideFcn='divideblock'%###I'mthinkingofusing0.8/0.2/0astrn/val/tstheresincethedataI'mabouttopredictmayberegardedasthetstdata.I'm
thinkingthatoptimalinputparametersshouldalreadybeobtainedatthisstage,thereshouldthusnotbeanyneedtotestthemodel.###
netc.trainParam.max_fail=10
%view(netc)
[Xc,Xci,Aci,Tc]=preparets(netc,{},{},T)
isequal(Tc,To),tc=to%1

[netc,tro,Yc,Ec,Acf,Xcf]=train(netc,Xc,Tc,Xci,Aci)%###1.(Reference,seethreelinesbelow)
[Yc,Xcf,Acf]=netc(Xc,Xci,Aci)%###2.(Reference,seetwolinesbelow)

%###Abovearetwolineswithreferences1.and2..Forsomereasonthis
%trainingofthecloseloopdoesnotalterYccomparedtoNOTdoingthe
%trainingandjustusingtheYcobtainedfromthe2.(netc(..)).Iseems
%togetnodifferentvaluesifputa%before1.
%nntraintoolrunsintheCLconfigbutisseemsasifthisdoesnotdoanything.
%IhavereadaboutthattheweightsfromOLshouldbeusedasinputfortheCL,
%isthistakencareofwiththe"netc=closeloop(neto)"command?
%...or,shouldIuseotherinputsthannetc,Xc,Tc,Xci,Aciwhentrainingtheclosednetwork?###

Ec=gsubtract(Tc,Yc)
yc=cell2mat(Yc)
NMSEc=mse(Ec)/var(tc,1)
[Yc,Xcf,Acf]=netc(Xc,Xci,Aci)%Iwonderifthisisnecessary...?
Xc2=cell(1,N)
[Yc2,Xcf2,Acf2]=netc(Xc2,Xcf,Acf)
yc2=cell2mat(Yc2)

plt=plt+1figure(plt),holdon
plot(d+1:N,tc,'LineWidth',2)
plot(d+1:N,yc,'o','LineWidth',2)
plot(N+1:2*N,yc2,'ro','LineWidth',2)
plot(N+1:2*N,yc2,'r','LineWidth',2)

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

8/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

%axis([02*N+201.3])
legend('TARGET','OUTPUT','TARGETLESSPREDICTION')
title('CLOSEDLOOPNARNETRESULTS')

Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
From:GregHeath
Date:30Apr,201603:33:03
Message:3of5
Replytothismessage
RemoveauthorfromMyWatchList
Vieworiginalformat
Flagasspam
%Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
%From:Staffan
%Date:29Apr,201617:50:03
%Message:2of2
closeallclearallclearvarsplt=0
GEH1='STARTTIMING',tic
T=solar_dataset
t=cell2mat(T)
[O,N]=size(t)%'O'FOR'"o"utput
GEH2=['REMOVESEMICOLON[ON]==>[12899]']
GEH3=['TOINSUREUNBIASEDNONTRAININGPREDICTIONS'...
'USEDIVIDEBLOCKANDTHENUSENtrninNNCORR']
GEH4=['Ntrn=N2*round(0.15*N)=2029']
%###OnethingIthinkofinitiallyistheuseoftrainingalgoritm,
%shouldonealwaysfirstusetrainlminallsteps(OLandCL)or
%isthereascientificapproachthatcandetermine(beforetrainingis
%started)ife.g.trainbrwouldfitaspecificsignalbetter?###
GEH5=['IDON"TKNOW.BESTTOBEGINWITHDEFAULTS'...
'THENSEEMYSPIELSONOVERTRAINING,HubANDMSEREG']
MSE00=var(t',1),GEH6=['TAKEMEANIFifO>1']
zt=zscore(t',1)'
plt=plt+1
figure(plt)
subplot(211)
plot(t)
title('SOLARDATASET')
subplot(212)
plot(zt)
title('SOLARDATASET,STANDARDIZED')
GEH7=['MINMAXztCHECKFOROUTLIERS?']
rng('default')
L=floor(0.95*(2*N1))%189
GEH8=['JUSTUSENtrn,LtrnFORSIGLAGS']
fori=1:100
n=randn(1,N)
autocorrn=nncorr(n,n,N1,'biased')
sortabsautocorrn=sort(abs(autocorrn))
thresh95(i)=sortabsautocorrn(L)
end

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

9/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

sigthresh95=mean(thresh95)%0.2194
GEH9=['UHOH...THAT"SNOTWHATIGET!']
GEH10=['ALSOGOODTOKNOWOTHERSTATS']
minthresh95=min(thresh95)%0.024638
medthresh95=median(thresh95)%0.027242
meanthresh95=mean(thresh95)%0.0273
stdthresh95=std(thresh95)%0.0011573
maxthresh95=max(thresh95)%0.030326
GEH11=['MIGHTWANTTOKNOWWHATIFmax(i)>100']
autocorrt=nncorr(zt,zt,N1,'biased')
%siglag95=1+find(abs(autocorrt(N:2*N1))>=sigthresh95)
siglag95=1+find(abs(autocorrt(N:2*N1))>=0.25)
%###MemoryismaxingoutifIusealllagvaluesfromtheaboveline
%probablythisisoneofthemostimportantimprovementareas###
GEH12=['1.ONLYNEEDASUFFICIENTSUBSET'...
'2.ITHINKYOURINITIALCALCULATIONISFLAWED']

plt=plt+1figure(plt)
holdon
plot(0:N1,sigthresh95*ones(1,N),'b')
plot(0:N1,zeros(1,N),'k')
plot(0:N1,sigthresh95*ones(1,N),'b')
plot(0:N1,autocorrt(N:2*N1))
plot(siglag95,autocorrt(N+siglag95),'ro')
title('REDUCEDNUMBEROFAUTOCORRELATIONSINSOLARDATASET')
GEH13=['NOTSUREWHATTHATMEANS']
best_Y=[]
NMSEin=Inf
i=0
rng('default')%###Shouldthisbeplacedinsideoroutsideofthefor...'
%(n)looporthefor(j)loop?Whatdifferencedoesthesethreealternativesgive?###
GEH14=['ALLYOUNEEDTOKNOWISWHATTHERNGSTATEIS'...
'FORADESIGNYOUWANTTOEPRODUCE']
.['SEEMYCODES']

min_nodes=2
max_nodes=15
GEH15=['JUSTIFICATIONFORTHESENUMBERS?...Hub=?']
trails=10
GEH16=['Ntrials=NumberoftrialsNOTtrails']
GEH17=['Definenarnet(FD,n)inouterloop.Ntrialsofinitialrandomweightsininnerloop'...
'butNOTrandomdatadivisionfortimeseries..getnonuniformtimespacing']
GEH18='MORELATER'
Greg

Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
From:GregHeath
Date:1May,201608:16:03
Message:4of5
Replytothismessage
RemoveauthorfromMyWatchList

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

10/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

Vieworiginalformat
Flagasspam
"GregHeath"<heath@alumni.brown.edu>wroteinmessage<ng191f$5tr$1@newscl01ah.mathworks.com>...
>%Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
>%From:Staffan
>%Date:29Apr,201617:50:03
>%Message:2of2
>GEH18='MORELATER'
>forn=min_nodes:max_nodes%25%alotofpossibleoptionshere,usingmore...
%thanonehiddenlayerwouldbeinterestingtoinvestigate
i=i+1%Counterforindicesinsidethesecondloop(donottieupanythington).

forj=1:trails
net=narnet(siglag95(2:end),n)
GEH19='USETHESHORTESTSUBSETASPOSSIBLE'

net.divideFcn='divideblock'%Ididnottryrandomizingthesestateshereyet,possiblefutureimprovement...
GEH20=['FORTIMESERIESPREDICTIONTESTSUBSET'...
'MUSTOCCURAFTERTHETRAININGANDVALSUBSETS']
net.trainParam.max_fail=10
GEH21='WHY10?'
[Xo,Xoi,Aoi,To]=preparets(net,{},{},T)
[net,tr,Yo,Eo,Xof,Aof]=train(net,Xo,To,Xoi,Aoi)
%view(net)
Yo=net(Xo,Xoi,Aoi)
Eo=gsubtract(To,Yo)
GEH22='COMMENTPREVIOUSTWOSTATEMENTS'
NMSEo_temp(i,j)=mse(Eo)/MSE00
%thislooptakeslongtime,ifboredwatchthis
%https://www.youtube.com/watch?v=YVwQaQK9yu4
GEH23='BETTERTOJUSTUSEAREASONABLENUMBEROFDELAYS'
end

NMSEo=mean(NMSEo_temp(i,:))

GEH24='NO!FINDTHEBESTDESIGN,NOTTHEBESTAVERAGE!'
GEH25=['HOWEVERDOTABULATESUMMARYSTATSOF'...
'MIN,MEDIAN,MEAN,STDANDMAX']
if(NMSEo<NMSEin)
fprintf('BestNMSEsofar:%4.3f(for%dHiddennodes)\n',NMSEo,n)
NMSEin=NMSEo
best_Y=Yo
N_use=n

end

end
%Twoplotstolookaterrorvs.nodesandtrials
plt=plt+1figure(plt),holdon
plot(min_nodes:max_nodes,mean(NMSEo_temp'))
xlabel('Numberofnodes')
ylabel('NMSEo')
title('CorrelationbetweennumberofnodesandaverageofNMSEo')
holdoff

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

11/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

plt=plt+1figure(plt)
contourf(1:trails,min_nodes:max_nodes,NMSEo_temp)
xlabel('trialnumber')
ylabel('Numberofnodes')
title('Correlationbetweennumberofnodes,trialnumberandaverageofNMSEo')
%addxandylabels
%notetoselfaboveisfromthefile"autocorr_analysis"
%notetoselfbelowisfromthefile"narnet_solar"
'GEH24='BETTERTOPLOTMIN,MEDIAN,MEANANDMAX'...
'VSNO.OFLAGSANDNODES'
FD=siglag95(2:end)
FD_length=length(FD)
d=max(FD)
neto=narnet(FD,N_use)
neto.divideFcn='divideblock'
neto.trainParam.max_fail=10
%view(neto)
[Xo,Xoi,Aoi,To]=preparets(neto,{},{},T)
to=cell2mat(To)
zto=zscore(to,1)
varto1=mean(var(to',1))
minmaxto=minmax([tozto])%Isusedtocheckforoutliers,ifoutliersaredetectedthisshouldbeevaluatedatanearlierstage
plt=plt+1figure(plt),holdon
plot(d+1:N,to)%,'LineWidth',2)
rng('default')
[neto,tro,Yo,Eo,Aof,Xof]=train(neto,Xo,To,Xoi,Aoi)
[Yo,Xof,Aof]=neto(Xo,Xoi,Aoi)%[Yo,Xof,Aof]=net(Xo,Xoi,Aoi)Error?
Eo=gsubtract(To,Yo)
GEH25=['NOTANERRORJUSTANEXPLICTWAYTOGET'...
'Yo,Eo,Xof&AofINSTEADOFABYPRODUCTFROMTRAINING']
%view(neto)
NMSEo=mse(Eo)/varto1
%tro=tro%Nosemicolon.RevealstheOLtrainingrecord
yo=cell2mat(Yo)
plot(d+1:N,yo,'g')%,'ro','LineWidth',2)
%axis([010201.3])
legend('TARGET','OUTPUT')
title('OPENLOOPNARNETRESULTS')
netc=closeloop(neto)%[netc,Xci,Aci]=closeloop(neto,Xoi,Aoi)ErrorornotcompatiblewithR2012b?
GEH26='DUNNOTRYBOTH'
GEH27='NOWNEEDTOCHECKHOWGOODNETCIS'
netc.divideFcn='divideblock'%###I'mthinkingofusing0.8/0.2/0astrn/val/tstheresincethedataI'mabouttopredictmayberegardedasthetstdata.
GEH27='WHATDOYOUMEANREGARDED?ITISTHETESTDATA!!!']
GEH28=['WHENNISHUGECANAFFORDLARGERFRACTIONS'...
'FORVALANDTEST'[
I'mthinkingthatoptimalinputparametersshouldalreadybeobtainedatthisstage,thereshouldthusnotbeanyneedtotestthemodel.###

GEH29=['WHENINNNCOUNTRYBEVERYCAREFULHOW'...
'YOUMISUSETHEWORDSTESTANDVALIDATE!]

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

12/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

GEH30=['BECAREFUL:WHENYOUCLOSETHELOOPONA'...
'SUCCESFULNETOYOUMAYNOTGETASUCCESSFUL'...
'NETC!!!']
netc.trainParam.max_fail=10
%view(netc)
[Xc,Xci,Aci,Tc]=preparets(netc,{},{},T)
isequal(Tc,To),tc=to%1
[netc,tro,Yc,Ec,Acf,Xcf]=train(netc,Xc,Tc,Xci,Aci)%###1.(Reference,seethreelinesbelow)
[Yc,Xcf,Acf]=netc(Xc,Xci,Aci)%###2.(Reference,seetwolinesbelow)
%###Abovearetwolineswithreferences1.and2..Forsomereasonthis
%trainingofthecloseloopdoesnotalterYccomparedtoNOTdoingthe
%trainingandjustusingtheYcobtainedfromthe2.(netc(..)).Iseems
%togetnodifferentvaluesifputa%before1.
%nntraintoolrunsintheCLconfigbutisseemsasifthisdoesnotdoanything.
%IhavereadaboutthattheweightsfromOLshouldbeusedasinputfortheCL,
%isthistakencareofwiththe"netc=closeloop(neto)"command?
%...or,shouldIuseotherinputsthannetc,Xc,Tc,Xci,Aciwhentrainingtheclosednetwork?###
GEH31['SOMETIMESJUSTCLOSINGTHELOOPISSUFFICIENT'...
'OTHERTIMESYOUHAVETOTRAINNETCANDSOMETIMES'..
'THATISN'TGOODENOUGHSOYOUHAVETOSTARTOVER']
Ec=gsubtract(Tc,Yc)
yc=cell2mat(Yc)
NMSEc=mse(Ec)/var(tc,1)
[Yc,Xcf,Acf]=netc(Xc,Xci,Aci)%Iwonderifthisisnecessary...?
GEH32=['ONLYIFYOUWANTTOPREDICTBEYONDN']
Xc2=cell(1,N)
[Yc2,Xcf2,Acf2]=netc(Xc2,Xcf,Acf)
yc2=cell2mat(Yc2)
plt=plt+1figure(plt),holdon
plot(d+1:N,tc,'LineWidth',2)
plot(d+1:N,yc,'o','LineWidth',2)
plot(N+1:2*N,yc2,'ro','LineWidth',2)
plot(N+1:2*N,yc2,'r','LineWidth',2)
%axis([02*N+201.3])
legend('TARGET','OUTPUT','TARGETLESSPREDICTION')
title('CLOSEDLOOPNARNETRESULTS')
totaltime=toc

HOPETHISHELPS
GREG

Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
From:GregHeath
Date:5May,201601:14:03
Message:5of5
Replytothismessage
RemoveauthorfromMyWatchList
Vieworiginalformat
Flagasspam
"GregHeath"<heath@alumni.brown.edu>wroteinmessage<nesgmv$jo4$1@newscl01ah.mathworks.com>...
>Subject:REVISITED:NARNETTUTORIALONMULTISTEPAHEADPREDICTIONS
>
>NOINPUT/POSTTARGETMULTISTEPTIMESERIESPREDICTION(NARNET)
>Reference:http://www.mathworks.com/matlabcentral/newsreader/...

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

13/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

>view_thread/338508#945325
>
>1.Idon'trecommendusingntstoolforcomplicatedproblemsuntilyouaremoreexperienced.Thecommandlinescriptitgeneratesofferssomanyoptionsthatit
obscuresthemostimportantchoices.Thealternativeistofirstusetheabbreviatedscriptsinthehelpanddocdocumentationthattakeadvantageofdefault
optionsanduseMATLABexampledatathatcanbeobtainedfromthehelpanddoccommands
>
>helpnndatasets
>docnndatasets
>
>Thiswillnotonlyprepareyoubetterwithbasics,itwillmakeiteasierforustohelpifyouhavedifficulties.
>
>2.Whenyouonlyhaveoneseries,theappropriatefunctiontouseisNARNET.Firstobtainandcomparethedocumentationandsimplecodeexamplesobtained
fromthecommands
>
>helpnarnet
>docnarnet
>
>Second,noticethatdifferentnotationisused.Ipreferthenotationindocnarnetbecauseitdoesnotuselowercaseforcellvariables.However,insteadofusing
the"s"subscripttoindicatevariablesusedintheopenloop"s"eries.Iprefertousethemoreobviousnotations"o"andOLforopenloopalongwith"c"andCLfor
closedloop.
>
>Third,theexplanationindocERRONEOUSLYstatesthat0isanallowableoutputfeedbackdelay.ITISNOT!Inparticular:
>
>ItisonlyallowableintheOLconfigurationbecausetheprogramconsidersitasanexternalinput.However,itisnotallowableintheCLconfiguration.So,Isee
nogoodreasonforusingit.
>
>3.TheexamplesusethedefaultdatadivisonoptionDIVIDERANDwhichcreatesrandomnonuniformtimestepswithinthetraining,validationandtestsubsets.
Thisisgreatforregressionandclassification.Fortimeseriesprediction,however,itcanbeDISASTEROUS!
>
>Thereareavarietyofwaystoobtainuniformtimestepswithinthesubsetsusingotherdatadivisionoptions.IfavorDIVIDEBLOCKwhichyieldstheindexing
>
>[1:Ntrn,Ntrn+1:Ntrn+Nval,Ntrn+Nval+1:N]
>
>whereN=Ntrn+Nval+Ntst.Thedefaultpercentagesare0.7/0.15/0.15.
>
>4.Theexampleindocyieldsascaledependentvaluefortheperformancewhichisrepeatableonlyiftheinitialstateoftherandomnumbergeneratorisknown.
>
>5.Ipreferthefollowingversionthat
>(a)Explicitlyshows
>i.ThesizeoftheinputandtargetinBOTHcellandmatrixformat
>ii.Theminandmaxvaluesofinputandtarget
>iii.Thecorrespondingminandmaxvaluesofthestandardized
>(i.e.,zeromean/unitvariance)valuesforoutlierdetection
>iv.Theaveragetargetvariancethatwillbeusedasthereference
>meansquareerror
>(b)ShowsthemostgeneralformofthesyntaxontheLHSoftrainingand
>outputequations.However,somemaynotbevalidforversionsolder
>thanR2014a,thereforealternateformatsarealsoshown(but
>commented)
>(c)Specifiestheinitialrandomnumberstatesothattheexamplecanbe
>duplicatedexactly
>(d)Usesascaleindependentnormalizationforthemeansquareerror
>performancevaluethatindicatesthefractionofthetargetvariance
>thatisnotmodelledbythenet.
>6.Beforeusingyourowndata,itisSTRONGLYRECOMMENDEDtopracticeonMATLABexampledataobtainedfrom
>
>helpnndatasets
>docnndatasets
>
>Thatwillmakeiteasierforustohelpifyouhaveproblems.
>7.Finally,theexamplebelowassumesthatthedefaultfeedbackdelay(FD)andnumberofhiddennode(H)parametersaresufficient.Ingeneral,theywillnot
be.Myapproachtothisdifficultyis
>a.ChooseFDfromasubsetofthedelayscorrespondingtostatistically
significantvaluesofthetrainingtargetautocorrelationfunction(e.g.,NNCORRwithNtrn).
>b.GivenatrialvalueofFD,useadoubleforloopsearch:
>
>forh=Hmin:dH:Hmax%Numberofhiddennodes
>...
>fori=1:Ntrials%Randominitialweights

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

14/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

>...
>end
>end
>c.ManyexamplesofthisapproachhavebeenpostedintheNEWSGROUPandANSWERS.IncludethenameofthecorrelationfunctionNNCORRasa
searchword.
>
>closeall,clearall,clc,plt=0
tic%Starttimer
>T=simplenar_dataset
[I0N]=size(T)%[1100]
t=cell2mat(T)
[IN]=size(t)%[1100]
%NOTE:SometimesI>I0
>d=2,FD=1:dH=10%MATLABdefaults
>neto=narnet(FD,H)
>neto.divideFcn='divideblock'
>view(neto)
>[Xo,Xoi,Aoi,To]=preparets(neto,{},{},T)
>to=cell2mat(To)%to=t(d+1:N)
zto=zscore(to,1)
>varto1=mean(var(to',1))%0.061307MSEreference
>minmaxto=minmax([tozto])
>%minmaxto=0.239110.99991
>%1.97631.0963
>%Nooutliers
>
>plt=plt+1figure(plt),holdon
>plot(d+1:N,to,'LineWidth',2)
>
>rng('default')%Forreproducibility
>[netotroYoEoAofXof]=train(neto,Xo,To,Xoi,Aoi)
%Alternatecalculationsforolderversions
%[YoXofAof]=net(Xo,Xoi,Aoi)%Eo=gsubtract(To,Yo)
>view(neto)
>NMSEo=mse(Eo)/varto1%6.6721e09
>
>%tro=tro%Nosemicolon.RevealstheOLtrainingrecord
>
>yo=cell2mat(Yo)
>plot(d+1:N,yo,'ro','LineWidth',2)
>axis([010201.3])
>legend('TARGET','OUTPUT')
>title('OPENLOOPNARNETRESULTS')
>
>7.Now,theoutputfeedbackloopisclosedandtestedsothatpredictionscaneventuallybeextendedbeyondthetimeoftheknowntarget,T.
>
>[netcXciAci]=closeloop(neto,Xoi,Aoi)
>view(netc)
>[Xc,Xci,Aci,Tc]=preparets(netc,{},{},T)
>isequal(Tc,To),tc=to%1
>[YcXcfAcf]=netc(Xc,Xci,Aci)
>Ec=gsubtract(Tc,Yc)
>yc=cell2mat(Yc)
>NMSEc=mse(Ec)/var(tc,1)%3.2807e07
>
>Althoughtheperformanceisafactorof50worse,itisstillexcellent.Ifitweresignificantlydegraded(e.g.,below~0.005),netcwouldbetrainedstartingwiththe
weightsobtainedintheopenloopstage(NOTE:Thisisnotmentionedineitherthehelpordocdocumentation).
>
>8.Theremovedelayfunctionisincludedinbothdocumentations.However,Iseenogoodreasonforusingithere.Forexample,whenusedwiththedefault
outputfeedbackdelay1:2,ityieldsinvalidzeroand/ornegativevalues.

>ISTHISABUGTHATNEEDSTOBEFIXED?
>
>9.Toextendthepredictionbeyondtheendoftheknownseries,emptycellsareusedasinputsandthefinaldelaystatesXcfandAcfareusedasinitial
conditions.
>
>[YcXcfAcf]=netc(Xc,Xci,Aci)
M=N%Anarbitrarychoice
Xc2=cell(1,M)

MATLABNewsgroup

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

15/16

12.11.2016.

MATLABCentralREVISITED:NARNETTUTORIALONMULTISTEPAHEADPRED...

>[Yc2Xcf2Acf2]=netc(Xc2,Xcf,Acf)
>yc2=cell2mat(Yc2)
>
>plt=plt+1figure(plt),holdon
>plot(d+1:N,tc,'LineWidth',2)
>plot(d+1:N,yc,'o','LineWidth',2)
plot(N+1:N+M,yc2,'ro','LineWidth',2)
plot(N+1:N+M,yc2,'r','LineWidth',2)
>axis([02*N+201.3])
>legend('TARGET','OUTPUT','TARGETLESSPREDICTION')
>title('CLOSEDLOOPNARNETRESULTS')
Ingeneral,thedefaultvaluesFD=1:2andH=10areneitheroptimalnorsufficient.Whendissatisfiedwiththedefaults,ItypicallyuseNtrninNNCORRtoobtain
thetrainingdataautocorrelationfunctionandlagscorrespondingtostatisticallysignificantvalues.SubsetsofthesignificantlagsarethenusedasNARNET
feedbackdelays.Plotsoftheautocorrelationfunctionwithstatisticallysignificantvalueshighlightedareusefulforunderstandingtheinfluenceofdifferentdelays.
Topreventpoorperformanceonnontrainingdata,thenumberofdelaysandhiddennodesareonlychosenhighenoughtoobtainthespecifiedtrainingMSEgoal.
Therefore,ingeneral,designisatrialanderrorprocess.
Ifhighvaluesoflagsandhiddennodesarerequired,overtrainingmitigation
procedureslikeVALIDATIONSTOPPINGandBAYESIANREGULARIZATIONmayhavetobeconsidered.
>Hopethishelps.
>
>Greg

FeedforthisThread
AddtoMyWatchList
WhatisaWatchList?

TagsforthisThread
tutorial, neuralnetwork, narnetsolar_datas...

AddaNewTag:

Add

Whataretags?
Atagislikeakeywordorcategorylabelassociatedwitheachthread.Tagsmakeiteasierforyoutofindthreadsofinterest.
Anyonecantagathread.Tagsarepublicandvisibletoeveryone.

MATLABNewsgroup

19942016TheMathWorks,Inc.

https://www.mathworks.com/matlabcentral/newsreader/view_thread/345189#945495

16/16

Anda mungkin juga menyukai