資源描述:
《bp神經(jīng)網(wǎng)絡(luò)matlab實例(bp神經(jīng)網(wǎng)絡(luò)matlab實例)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、bp神經(jīng)網(wǎng)絡(luò)matlab實例(bp神經(jīng)網(wǎng)絡(luò)matlab實例)Case1trainingBPnetworkbymomentumgradientdescentalgorithm.Trainingsamplesaredefinedasfollows:InputvectorasP=[-1-231-115-3]Thetargetvectorist=[-1-111]Solution:theMATLABprogramofthisexampleisasfollows:CloseallClearEchoonCLC%NEWFF-generatinganewfeedforw
2、ardneuralnetwork%TRAIN--trainingBPneuralnetwork%SIM--SimulationofBPneuralnetworkPauseStartbyhittinganykeyCLCPercentdefinestrainingsamples%PasinputvectorP=[-1,-2,3,1;-1,1,5,-3];%TisthetargetvectorT=[-1,-1,1,1];Pause;CLC%createanewfeedforwardneuralnetworkNet=newff(minmax(P),[3,1],
3、{'tansig','purelin'},'traingdm')ThecurrentinputlayerweightsandthresholdsInputWeights=net.IW{1,1}Inputbias=net.b{1}ThecurrentnetworklayerweightsandthresholdsLayerWeights=net.LW{2,1}Layerbias=net.b{2}PauseCLC%settrainingparametersNet.trainParam.show=50;Net.trainParam.lr=0.05;Net.t
4、rainParam.mc=0.9;Net.trainParam.epochs=1000;Net.trainParam.goal=1e-3;PauseCLC%callTRAINGDMalgorithmtotrainBPnetwork[net,tr]=train(net,P,T);PauseCLCSimulationofBPnetworkby%A=sim(net,P)CalculatethesimulationerrorE=T-AMSE=mse(E)PauseCLCEchooffExample2adoptsBayesianregularizationalg
5、orithmtoimprovethegeneralizationabilityofBPnetwork.Inthiscase,weusedtwokindsoftrainingmethods,namelyL-Malgorithm(trainlm)andtheBiasregularizationalgorithm(trainbr),isusedtotraintheBPnetwork,sothatitcanfitattachedtoawhitenoisesinesampledata.Amongthem,thesampledatacanbegeneratedas
6、followsMATLABstatements:Inputvector:P=[-1:0.05:1];Targetvector:randn('seed',78341223);T=sin(2*pi*P)+0.1*randn(size(P));Solution:theMATLABprogramofthisexampleisasfollows:CloseallClearEchoonCLC%NEWFF-generatinganewfeedforwardneuralnetwork%TRAIN--trainingBPneuralnetwork%SIM--Simula
7、tionofBPneuralnetworkPauseStartbyhittinganykeyCLC%definetrainingsamplevector%PasinputvectorP=[-1:0.05:1];%TisthetargetvectorRandn('seed',78341223);T=sin(2*pi*P)+0.1*randn(size(P));DrawthesampledatapointsPlot(P,T,+);EchooffHoldon;Plot(P,sin(2*pi*P),':');Drawsinecurveswithoutnoise
8、EchoonCLCPauseCLC%createanewfeedforwardneuralne