资源简介

本程序用模糊神经网络逼近数学函数,已经在MATLAB上运行通过,有兴趣的朋友可以参考一下。

资源截图

代码片段和文件信息

%模糊神经网络逼近函数
clear all
close all
rank=8;
step=20;%循环次数
FF2=zeros(2*rank1);
W=ones(1rank*rank);%权值
WK1=W;
WK2=W;
WW=zeros(rank*rank1);
gama=0.618;%记忆权值
beta=0.7;%学习步长
for x1=-1:0.1:1
    for x2=-1:0.1:1
        %第一层的输入
        input1=[x1x2]‘;
        FF2=[-1 -0.7 -0.4 -0.1 0.1 0.4 0.7 1; -1 -0.7 -0.4 -0.1 0.1 0.4 0.7 1];
        width=[0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7  ;0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7  ];%隶属度宽度
        XX2=zeros(length(input1)rank);
        for i=1:length(input1)
            for j=1:rank
                XX2(ij)=-(input1(i)-FF2(ij))^2/width(ij)^2;
            end
        end;
        miu=exp(XX2);
        for i=1:length(input1)
            for j=1:rank
                if miu(ij)<0.1
                    miu(ij)=0;
                end
            end
        end 
        FF3=zeros(rankrank);
        for i=1:rank
            for j=1:rank
                FF3(ij)=min(miu(1i)miu(2j));
            end
        end;
        FF4=zeros(rankrank);
        temp=0;
        for i=1:rank
            for j=1:rank
                temp=temp+FF3(ij);
            end
        end
        for i=1:rank
            for j=1:rank
                FF4(ij)=FF3(ij)/temp;
            end
        end
        XX4=zeros(rank*rank1);
        XX4=reshape(FF4rank*rank1);
        t=sin(x1*pi)*sin(pi*x2);
        for train=1:step
            YY=W*XX4;
            for j=1:length(W)
                W(j)=WK1(j)+beta*(t-YY)*XX4(j)+gama*(WK1(j)-WK2(j));
            end
            WK2=WK1;
            WK1=W;
        end
        WW=[WWW‘];
    end

end
%训练结束
YY=0;
GG=0;
K

评论

共有 条评论