function [w1,w2,width,rule,e,RMSE]=DFNN(p,t,parameters)
% This is D_FNN trainning program.
% Input:
% p is the input data,which is r by q matrix.
% r is the No. of input.
% t is the output data,whic is s2 by q matrix.
% q is the No. of sample data.
% Output:
% w1 is the centers of the RBF units,which is a u by r matrix.
% w2 is the weights,which is s2 by u(1+r) matrix.
% width is the widths of RBF units,which is a 1 by u matrix.
if nargin<2
error('Not enough input arguments.')
end
if size(p,2)~=size(t,2)
error('The input data are not correct.')
end
[r,q]=size(p);[s2,q]=size(t);
%Setting predefined parameters
kdmax=parameters(1);kdmin=parameters(2);gama=parameters(3);
emax=parameters(4);emin=parameters(5);beta=parameters(6);
width0=parameters(7);k=parameters(8);kw=parameters(9);
kerr=parameters(10);
ALLIN=[];ALLOUT=[];CRBF=[];
%When first sample data coming
ALLIN=p(:,1);ALLOUT=t(:,1);
%Setting up the initial DFNN
CRBF=p(:,1);w1=CRBF';width(1)=width0;rule(1)=1;
%Caculating the first out error
a0=RBF(dist(w1,ALLIN),1./width');
a01=[a0 p(:,1)'];
w2=ALLOUT/a01';
a02=w2*a01';
RMSE(1)=sqrt(sumsqr(ALLOUT-a02)/s2);
%When other sample data coming
for i=2:q
IN=p(:,i);OUT=t(:,i);
ALLIN=[ALLIN IN];
ALLOUT=[ALLOUT OUT];
[r,N]=size(ALLIN);[s,r]=size(w1);
dd=dist(w1,IN);
[d,ind]=min(dd);
kd=max(kdmax*gama.^(i-1),kdmin);
%Caculating the actual output of its sample data
ai=RBF(dist(w1,IN),1./width');
ai=ai/sum(ai);ai1=transf(ai,IN);
ai2=w2*ai1;
errout=t(:,i)-ai2;
errout=sum(errout.*errout)/s2;
e(i)=sqrt(errout);
ke=max(emax*beta.^(i-1),emin);
if d>kd
if e(i)>ke
CRBF=[CRBF IN];%Add a new rule
wb=k*d;
width=[width wb];
w1=CRBF';
[u,v]=size(w1);
%Calculating ouputs of RBF after growing for all data
A=RBF(dist(w1,ALLIN),1./width');
A0=sum(A);
A1=A./(ones(u,1)*A0);
A2=transf(A1,ALLIN);
if u*(r+1)<=N
%Caculating error reduction rate
tT=ALLOUT';
PAT=A2';
[W,AW]=orthogonalize(PAT);
SSW=sum(W.*W)';SStT=sum(tT.*tT)';
err=((W'*tT)'.^2)./(SStT*SSW');errT=err';
err1=zeros(u,s2*(r+1));
err1(:)=errT;err21=err1';
err22=sum(err21.*err21)/(s2*(r+1));
err23=sqrt(err22);
No=find(err23<kerr);
if ~isempty(No)
CRBF(:,No)=[];w1(No,:)=[];
width(:,No)=[];err21(:,No)=[];
[uv,vv]=size(w1);
AA=RBF(dist(w1,ALLIN),1./width');
AA0=sum(AA);
AA1=AA./(ones(uu,1)*AA0);
AA2=transf(AA1,ALLIN);
w2=ALLOUT/AA2;
outAA2=w2*AA2;
sse0=sumsqrt(ALLOUT-outAA2)/(i*s2);
RMSE(i)=sqrt(sse0);
rule(i)=uu;
w2T=w2';ww2=zeros(uu,s2*(r+1));
ww2(:)=w2T;
w21=ww2';
else
w2=ALLOUT/A2; %w2 is s2*u(r+1)
outA2=w2*A2;
sse0=sumsqr(ALLOUT-outA2)/(s2*i);
RMSE(i)=sqrt(sse0);
rule(i)=u;
w2T=w2';ww2=zeros(u,s2*(r+1));
ww2(:)=w2T;
w21=ww2';
end
else
w2=ALLOUT/A2;
outA2=w2*A2;
sse0=sumsqr(ALLOUT-outA2)/(s2*i);
RMSE(i)=sqrt(sse0);
rule(i)=u;
w2T=w2';ww2=zeros(u,s2*(r+1));
ww2(:)=w2T;
w21=ww2';
end
else
a=RBF(dist(w1,ALLIN),1./width');
a0=sum(a);a1=a./(ones(s,1)*a0);
a2=transf(a1,ALLIN);
w2=ALLOUT/a2;
outa2=w2*a2;
sse1=sumsqr(ALLOUT-outa2)/(s2*i);
RMSE(i)=sqrt(sse1);
rule(i)=s;
end
else
if e(i)>ke;
width(ind)=kw*width(ind);
aa=RBF(dist(w1,ALLIN),1./width');
aa0=sum(aa);aa1=aa./(ones(s,1)*aa0);
aa2=transf(aa1,ALLIN);
w2=ALLOUT/aa2;
outaa2=w2*aa2;
sse2=sumsqr(ALLOUT-outaa2)/(i*s2);
RMSE(i)=sqrt(sse2);
rule(i)=s;
else
aa1=RBF(dist(w1,ALLIN),1./width');
aa01=sum(aa1);aa11=aa1./(ones(s,1)*aa01);
aa21=transf(aa11,ALLIN);
w2=ALLOUT/aa21;
outaa21=w2*aa21;
sse3=sumsqr(ALLOUT-outaa21)/(s2*i);
RMSE(i)=sqrt(sse3);
rule(i)=s;
end
end
end
function[w,a]=orthogonalize(p)
%This program is used to transform p into orthogonalize w
[u,v]=size(p);w(:,1)=p(:,1);a=eye(v);
for k=2:v
b=zeros(u,1);
for i=1:k-1
a(i,k)=w(:,1)'*p(:,k)/(w(:,i)'*w(:,i));
b=b+a(i,k)*w(:,i);
end
w(:,k)=p(:,k)-b;
end
模糊神经网络,可自动调节模糊规则
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
Kevin_saec
- 粉丝: 1
- 资源: 2
最新资源
- vbf2.2.0-2.2.3
- PTC Creo Illustrate 是一款专业的技术插图软件,帮助用户创建、管理和发布高质量的三维技术插图
- 最详细的python安装教程,跟着操作即可,最好保证电脑的网络稳定情况下安装.zip
- 在python开发环境下爬虫爬取手机App数据实战并存入MongoDB.zip
- 浅谈网文教程(91).zip
- 2024 年最新中国大学名单
- Indexea 搜索服务平台的 OpenAPI,用于描述平台的所有接口信息,可以通过这个页面来了解和在线验证平台的所有接口信息
- 利用powerworld软件进行电力系统故障仿真
- 大学生计算机网络基础教程PDF,打破计算机文盲的现象,通俗易懂上手快.zip
- 正确打开网络安全学习路线,循序渐进,从认知到深入理解,最终达到应用的目的.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)