资源描述:
《自适应模糊神经网络MATLAB代码.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、function[c,sigma,W_output]=SOFNN(X,d,Kd)%SOFNNSelf-OrganizingFuzzyNeuralNetworks%InputParameters%X(r,n)-rthtraningdatafromnthobservation%d(n)-thedesiredoutputofthenetwork(mustbearowvector)%Kd(r)-predefineddistancethresholdfortherthinput%OutputParameters%c(IndexInp
2、utVariable,IndexNeuron)%sigma(IndexInputVariable,IndexNeuron)%W_outputisavector%SettingupParametersforSOFNNSigmaZero=4;delta=0.12;threshold=0.1354;k_sigma=1.12;%Formoreaccurateresultsuncommentthefollowing%formatlong;%ImplementationofaSOFNNmodel[size_R,size_N]=size
3、(X);%size_R-thenumberofinputvariablesc=[]; sigma=[]; W_output=[];u=0;%thenumberofneuronsinthestructureQ=[];O=[];Psi=[];forn=1:size_N x=X(:,n); ifu==0%Noneuroninthestructure? c=x; sigma=SigmaZero*ones(size_R,1); u=1; Psi=GetMePsi(X,c,sigma)
4、; [Q,O]=UpdateStructure(X,Psi,d); pT_n=GetMeGreatPsi(x,Psi(n,:))'; else [Q,O,pT_n]=UpdateStructureRecursively(X,Psi,Q,O,d,n); end; KeepSpinning=true; whileKeepSpinning %Calculatetheerrorandif-partcriteria ae=abs(d(n)-pT_n*O);%app
5、roximationerror [phi,~]=GetMePhi(x,c,sigma); [maxphi,maxindex]=max(phi);%maxindexreferstotheneuron'sindex ifae>delta ifmaxphi6、ex)=k_sigma*minsigma; Psi=GetMePsi(X,c,sigma); [Q,O]=UpdateStructure(X,Psi,d); pT_n=GetMeGreatPsi(x,Psi(n,:))'; else %Addanewneuronandupdatestructure ctemp=[]; sigmatemp=[];
7、 dist=0; forr=1:size_R dist=abs(x(r)-c(r,1)); distIndex=1; forj=2:u ifabs(x(r)-c(r,j))8、 ifdist<=Kd(r) ctemp=[ctemp;c(r,distIndex)]; sigmatemp=[sigmatemp;sigma(r,distIndex)]; else