该程序为文本文档

源代码在线查看: bp.txt

软件大小: 2 K
上传用户: bobar
关键词: 程序 文档
下载地址: 免注册下载 普通下载 VIP

相关代码

				bp神经网络设计源程序
				clear
				c=load('d:\c.txt');
				a=load('d:\a.txt');
				c=c';
				a=a';
				n=0;
				dsum=1;
				v=abs(randn(3,6)); %输入层至隐含层连接权
				z1=randn(3,1);%输入层阈值
				z=zeros(3,5);
				z(:,1)=z1;
				z(:,2)=z1;
				z(:,3)=z1;
				z(:,4)=z1;
				z(:,5)=z1;
				s=zeros(3,5);
				b=zeros(3,5);
				%隐含层至输出层
				w=abs(randn(2,3)); %隐含层至输出层连接权
				zy1=randn(2,1);%隐含层阈值
				zy(:,1)=zy1;
				zy(:,2)=zy1;
				zy(:,3)=zy1;
				zy(:,4)=zy1;
				zy(:,5)=zy1;
				l=zeros(2,5);
				cc=zeros(2,5);
				con=[1 1 1 1 1; 1 1 1 1 1];
				d=zeros(2,5);
				con2=[1 1 1 1 1;1 1 1 1 1;1 1 1 1 1];
				SL1=randn(1,1);
				SL2=randn(1,1);
				while dsum>0.00001
				s=v*a+z;
				b=1./(1+exp(-s) );
				%隐含层至输出层
				l=w*b+zy;
				cc=1./(1+exp(-l));
				%计算误差
				j=c-cc; 
				d=j.*c.*(con-c);
				e=w'*d.*b.*(con2-b);
				SL1=abs(randn(1,1));
				SL2=abs(randn(1,1));
				w=w+SL1*d*b';
				zy=zy+SL1*d;
				v=v+SL2*e*a';
				z=z+SL2*e;
				dsum=0;
				for i=1:2
				for j=1:5
				dsum=dsum+abs(d(i,j));
				end
				end
				n=n+1;
				error(n)=dsum;
				end
				n1=1:n;
				plot(n1,error) 
							

相关资源