反向传播网络实现
来源:互联网 发布:用友软件售后电话 编辑:程序博客网 时间:2024/06/04 23:25
这个主要是实现训练过程核心代码
function bpn(t1,t2)%t1 is trainingset,t2 is trainingtarget
%BP Summary of this function goes here
% Detailed explanation goes here
w11=[1 0.78];
w12=[0.8 0.9];
w21=[1 0.6];
b=[0.7 0.6 0.5];
lr=0.6;%leraning rate
%lr=0.2;
%lr=0.05;
sumerr=0;
%err=1;
c=1;%record the number of iteration
while c>0
for i=1:1:130
x11 = w11*t1(:,i);
x12 = w12*t1(:,i);
x1=b(1)-(w11(1)*x11 + w11(2)*x11);
x2=b(2)-(w12(1)*x11 + w12(2)*x11);
Xout(1) = fun(x1);
Xout(2) = fun(x2);
x21 = Xout*w21';
x3=b(3)-(w21(1)*x21 + w21(2)*x21);
f = fun(x3);
aout(i)=f;
err = t2(i)-f;
Q3 = f*(1-f)*err;
sumerr=sumerr+0.5*err^2;
w21(1) = w21(1) + lr*Xout(1)*Q3;
w21(2) = w21(2) + lr*Xout(2)*Q3;
b(3) = b(3) - lr*Q3;
Q1 = Xout(1)*(1-Xout(1))*w21(1)*Q3;
w11(1) = w11(1) + lr*t1(1,i)*Q1;
w11(2) = w11(2) + lr*t1(2,i)*Q1;
b(1) = b(1) - lr*Q1;
Q2 = Xout(2)*(1-Xout(2))*w21(2)*Q3;
w12(1) = w12(1) + lr*t1(1,i)*Q2;
w12(2) = w12(2) + lr*t1(2,i)*Q2;
b(2) = b(2) - lr*Q2;
end
errset(c)=sumerr/130;
sumerr=0;
if abs(err)<0.2
break;
end
c=c+1;
end
fprintf('the c:');
fprintf('%3.0f ',c);
plot(errset);
xlabel('the number of iterations');
ylabel('the sum of the squared error');
title('Error rate analysis');
text(130,0.01,['The total iterations are ',num2str(c)]);
fprintf('the target:');
for j=1:1:130
fprintf('%3.0f ',t2(j));
end
fprintf('/n');
fprintf('the output:');
for k=1:1:130
fprintf('%3.0f ',aout(k));
end
fprintf('/n');
fprintf('the weights:');
disp(w11);
disp(w12);
disp(w21);
fprintf('the bias:');
disp(b);
plot(aout,'r*');%to compare the target and output by ploting them respectively
hold;
plot(t2,'o');
end
- 反向传播网络实现
- 反向传播神经网络(BP网络)介绍及Java实现
- 反向传播网络(BP 网络)
- 前馈网络及反向传播
- 前馈网络及反向传播
- 多层网络和反向传播笔记
- 实现一个反向传播人工神经网络
- BP反向传播算法Python简单实现
- 实现反向传播算法的细节
- 反向传播
- 反向传播
- 反向传播
- 反向传播
- 网络摘抄的BP反向传播算法的精髓
- 去年写过的一个反向传播算法的实现
- C++中反向传播算法的简单实现
- Python实现人工神经网络(反向传播算法)
- 神经网络中的反向传播的推导和python实现
- 这辈子见过的最诚实的清华女生
- 我必须努力
- 使用BasciExcel类读写中文乱码
- OV7670调试心得
- struts 框架
- 反向传播网络实现
- 总结C++中的所有强制转换函数(const_cast,reinterpret_cast,static_cast,dynamic_cast)
- 没事
- 原来公司可以上外网噶,以后这就是我的新基地啦
- 3月29日记
- 深度剖析云存储
- 光栅图形学之直线段扫描算法(中点画线法之matlab代码)
- NetBeans 时事通讯(刊号 # 96 - Mar 29, 2010)
- spring中C3P0的配置