BP和RBF神经网络比较

对比


BP和RBF神经网络比较_第1张图片

算法流程图

BP和RBF神经网络比较_第2张图片

算例分析

BP和RBF神经网络比较_第3张图片
%BP identification
%网络结构:2-6-1
%权值W1、W2为[-1,1]之间的随机值,η=0.50,α=0.05
clear all;
close all;
 
xite=0.50;
alfa=0.05;
 
w2=rands(6,1);
w2_1=w2;w2_2=w2_1;
 
w1=rands(2,6);
w1_1=w1;w1_2=w1;
 
dw1=0*w1;
 
x=[0,0]';
 
u_1=0;
y_1=0;
 
I=[0,0,0,0,0,0]';
Iout=[0,0,0,0,0,0]';
FI=[0,0,0,0,0,0]';
 
ts=0.001;
for  k=1:1:1000
   
time(k)=k*ts;
u(k)=0.50*sin(3*2*pi*k*ts);
y(k)=u_1^3+y_1/(1+y_1^2);
 
for  j=1:1:6   
     I(j)=x'*w1(:,j);
     Iout(j)=1/(1+exp(-I(j)));
end   
 
yn(k)=w2'*Iout;         % Output of NNI networks
 
e(k)=y(k)-yn(k);    % Error calculation
 
w2=w2_1+(xite*e(k))*Iout+alfa*(w2_1-w2_2);
 
for j=1:1:6
   FI(j)=exp(-I(j))/(1+exp(-I(j)))^2;
end
 
for i=1:1:2
   for j=1:1:6
      dw1(i,j)=e(k)*xite*FI(j)*w2(j)*x(i);
   end
end
w1=w1_1+dw1+alfa*(w1_1-w1_2);
 
x(1)=u(k);
x(2)=y(k);
 
w1_2=w1_1;w1_1=w1;
w2_2=w2_1;w2_1=w2;
u_1=u(k);
y_1=y(k);
end
figure(1);
plot(time,y,'r',time,yn,'b');
xlabel('times');ylabel('y and yn');
figure(2);
plot(time,y-yn,'r');
xlabel('times');ylabel('error');

输出:
BP和RBF神经网络比较_第4张图片
BP和RBF神经网络比较_第5张图片


%RBF identification
%网络结构:2-4-1
%初始值取C=[0.5 0.5]’,B=[1.5 1.5 1.5 1.5]’, η=0.50,α=0.05
clear all;
close all;
 
alfa=0.05;
xite=0.5;      
x=[0,0]';
 
b=1.5*ones(4,1);   
c=0.5*ones(2,4);   
w=rands(4,1);   
 
w_1=w;w_2=w_1;
c_1=c;c_2=c_1;
b_1=b;b_2=b_1;
d_w=0*w;
d_b=0*b;
y_1=0;
 
ts=0.001;
for k=1:1:2000
   
time(k)=k*ts;
u(k)=0.50*sin(1*2*pi*k*ts);
 
y(k)=u(k)^3+y_1/(1+y_1^2);  
 
x(1)=u(k);
x(2)=y(k);
   
for j=1:1:4
    h(j)=exp(-norm(x-c(:,j))^2/(2*b(j)*b(j)));
end
ym(k)=w'*h';
em(k)=y(k)-ym(k);
 
for j=1:1:4
   d_w(j)=xite*em(k)*h(j);
   d_b(j)=xite*em(k)*w(j)*h(j)*(b(j)^-3)*norm(x-c(:,j))^2;
  for i=1:1:2
   d_c(i,j)=xite*em(k)*w(j)*h(j)*(x(i)-c(i,j))*(b(j)^-2);
  end
end
   w=w_1+ d_w+alfa*(w_1-w_2);
   b=b_1+d_b+alfa*(b_1-b_2);
   c=c_1+d_c+alfa*(c_1-c_2);
   
y_1=y(k);
   
w_2=w_1;
w_1=w;
   
c_2=c_1;
c_1=c;
   
b_2=b_1;
b_1=b;
end
figure(1);
plot(time,y,'r',time,ym,'b');
xlabel('time(s)');ylabel('y and ym');
   
figure(2);
plot(time,y-ym,'r');
xlabel('time(s)');ylabel('identification error');

输出:
BP和RBF神经网络比较_第6张图片


BP和RBF神经网络比较_第7张图片



参考书籍:

刘金琨《智能控制》  PDF下载链接:http://pan.baidu.com/s/1dFxdoqt 密码:ehom



你可能感兴趣的:(#,【自动控制】)