自适应模糊神经网络MATLAB代码.docx

上传人:b****3 文档编号:2496373 上传时间:2022-10-30 格式:DOCX 页数:5 大小:14.98KB
下载 相关 举报
自适应模糊神经网络MATLAB代码.docx_第1页
第1页 / 共5页
自适应模糊神经网络MATLAB代码.docx_第2页
第2页 / 共5页
自适应模糊神经网络MATLAB代码.docx_第3页
第3页 / 共5页
自适应模糊神经网络MATLAB代码.docx_第4页
第4页 / 共5页
自适应模糊神经网络MATLAB代码.docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

自适应模糊神经网络MATLAB代码.docx

《自适应模糊神经网络MATLAB代码.docx》由会员分享,可在线阅读,更多相关《自适应模糊神经网络MATLAB代码.docx(5页珍藏版)》请在冰豆网上搜索。

自适应模糊神经网络MATLAB代码.docx

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(IndexInputVariable,IndexNeuron)

%sigma(IndexInputVariable,IndexNeuron)

%W_outputisavector

%SettingupParametersforSOFNN

SigmaZero=4;

delta=0.12;

threshold=0.1354;

k_sigma=1.12;

%Formoreaccurateresultsuncommentthefollowing

%formatlong;

%ImplementationofaSOFNNmodel

[size_R,size_N]=size(X);

%size_R-thenumberofinputvariables

c=[]; 

sigma=[]; 

W_output=[];

u=0;%thenumberofneuronsinthestructure

Q=[];

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);

      [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);%approximationerror

      [phi,~]=GetMePhi(x,c,sigma);

      [maxphi,maxindex]=max(phi);%maxindexreferstotheneuron'sindex

      ifae>delta

        ifmaxphi

          %enlargewidth

          [minsigma,minindex]=min(sigma(:

maxindex));

          sigma(minindex,maxindex)=k_sigma*minsigma;

          Psi=GetMePsi(X,c,sigma);

          [Q,O]=UpdateStructure(X,Psi,d);

          pT_n=GetMeGreatPsi(x,Psi(n,:

))';                     

        else

          %Addanewneuronandupdatestructure

          ctemp=[];

          sigmatemp=[];

          dist=0;

          forr=1:

size_R

              dist=abs(x(r)-c(r,1));

              distIndex=1;

              forj=2:

u

                ifabs(x(r)-c(r,j))

                  distIndex=j;

                  dist=abs(x(r)-c(r,j));

                end;

              end;

              ifdist<=Kd(r)

                ctemp=[ctemp;c(r,distIndex)];

                sigmatemp=[sigmatemp;sigma(r,distIndex)];

              else

                ctemp=[ctemp;x(r)];

                sigmatemp=[sigmatemp;dist];

              end;

          end;

          c=[cctemp];

          sigma=[sigmasigmatemp];

          Psi=GetMePsi(X,c,sigma);

          [Q,O]=UpdateStructure(X,Psi,d);

          KeepSpinning=false;

          u=u+1;

        end;

      else

        ifmaxphi

          %enlargewidth

          [minsigma,minindex]=min(sigma(:

maxindex));

          sigma(minindex,maxindex)=k_sigma*minsigma;

          Psi=GetMePsi(X,c,sigma);

          [Q,O]=UpdateStructure(X,Psi,d);

          pT_n=GetMeGreatPsi(x,Psi(n,:

))';           

        else

          %Donothingandexitthewhile

          KeepSpinning=false;           

        end;

      end;      

  end;

end;

W_output=O;

end

function[Q_next,O_next,pT_n]=UpdateStructureRecursively(X,Psi,Q,O,d,n)

%O=O(t-1)O_next=O(t)

p_n=GetMeGreatPsi(X(:

n),Psi(n,:

));

pT_n=p_n';

ee=abs(d(n)-pT_n*O);%|e(t)|

temp=1+pT_n*Q*p_n;

ae=abs(ee/temp);

ifee>=ae

  L=Q*p_n*(temp)^(-1);

  Q_next=(eye(length(Q))-L*pT_n)*Q;

  O_next=O+L*ee;

else

  Q_next=eye(length(Q))*Q;

  O_next=O;

end;

end

function[Q,O]=UpdateStructure(X,Psi,d)

GreatPsiBig=GetMeGreatPsi(X,Psi);

%M=u*(r+1)

%n-thenumberofobservations

[M,~]=size(GreatPsiBig);

%OthersWaysofgettingQ=[P^T(t)*P(t)]^-1

%**************************************************************************

%opts.SYM=true;

%Q=linsolve(GreatPsiBig*GreatPsiBig',eye(M),opts);

%

%Q=inv(GreatPsiBig*GreatPsiBig');

%Q=pinv(GreatPsiBig*GreatPsiBig');

%**************************************************************************

Y=GreatPsiBig\eye(M);

Q=GreatPsiBig'\Y;

O=Q*GreatPsiBig*d';

end

%Thisfunctionworkstoowithx

%(X=XandPsiisaMatrix)-GetsyouthewholeGreatPsi

%(X=xandPsiistherowrelatedtox)-Getsyoujustthecolumnrelatedwiththeobservation

function[GreatPsi]=GetMeGreatPsi(X,Psi)

%Psi-Inarowyougothroughtheneuronsandinacolumnyougothroughnumberof

%observations****Psi(#obs,IndexNeuron)****

GreatPsi=[];

[N,U]=size(Psi);

forn=1:

N

  x=X(:

n);

  GreatPsiCol=[];

  foru=1:

U

      GreatPsiCol=[GreatPsiCol;Psi(n,u)*[1;x]];

  end;

  GreatPsi=[GreatPsiGreatPsiCol];

end;

end

function[phi,SumPhi]=GetM

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 工作计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1