1 / 13

BP 算法汇总

BP 算法汇总. ( 1 ). ( 2 ). ( 3 ). sigmoid 函数(取值在 [0 , 1] 之间)的导数. sigmoid 函数(取值在 [0 , 1] 之间)的导数. 对称型 Sigmoid 函数(取值在 [-1 , 1] 之间. 对称型 Sigmoid 函数(取值在 [-1 , 1] 之间. 对称型 Sigmoid 函数的导数. BP 算法的实现(初始化). clear in=5; hid=5; out=1; N=2000; w2=rand(hid,in)-0.5; w3=rand(out,hid)-0.5;

Download Presentation

BP 算法汇总

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BP算法汇总 (1) (2) (3)

  2. sigmoid函数(取值在[0,1]之间)的导数

  3. sigmoid函数(取值在[0,1]之间)的导数

  4. 对称型Sigmoid函数(取值在[-1,1]之间

  5. 对称型Sigmoid函数(取值在[-1,1]之间

  6. 对称型Sigmoid函数的导数

  7. BP算法的实现(初始化) clear in=5; hid=5; out=1; N=2000; w2=rand(hid,in)-0.5; w3=rand(out,hid)-0.5; a=0.1; y(:,1:3)=zeros(1,3); u=2*(rand(1,N)-.5); for k=4:N y(k)=0.7*(y(k-1)*y(k-2)*y(k-3)*u(k-2)*(y(k-3)-1)+u(k-1))/(1+y(k-2)^2+y(k-3)^2); end

  8. BP算法的实现(前向计算) for k=4:N x1=[y(k-1)y(k-2)y(k-3)u(k-1)u(k-2)]; for i=1:hid x2(:,i)=sigmoid2(x1*w2(i,:)'); end y1(k)=sigmoid2(x2*w3'); e(k)=y(k)-y1(k); e1(k)=e(k)*e(k); mste(k)=sum(e1)/k; disp([k mste(k)]);

  9. BP算法的实现(误差反向传播) delt3=e(k)*(1-y1(k))*(1+y1(k))/2; for j=1:hid delt2(j)=(1+x2(j)).*(1-x2(j))./2.*delt3.*w3(j) ; w3(j)=w3(j)+a*delt3*x2(j) end for j=1:hid for l=1:in w2(j,l)=w2(j,l)+a*delt2(j)*x1(l); end end end %End of the train

  10. BP算法的实现(测试数据产生) for k=1:500 u(k)=sin(2*pi*k/250); end for k=501:1000 u(k)=0.8*sin(2*pi*k/250)+0.2*sin(2*pi*k/25); end for k=4:1000 y(k)=0.7*(y(k-1)*y(k-2)*y(k-3)*u(k-2)*(y(k-3)-1)+u(k-1))/(1+y(k-2)^2+y(k-3)^2); end

  11. BP算法的实现(测试数据产生) for k=4:1000 x1=[y(k-1)y(k-2)y(k-3)u(k-1)u(k-2)] for i=1:hid x2(:,i)=sigmoid2(x1*w2(i,:)'); end y1(k)=sigmoid2(x2*w3'); ee(k)=y(k)-y1(k); disp([k,ee(k)]); End

  12. BP算法的实现(学习结果显示) clf t=1:1000; subplot(211),plot(t,y(t),'r',t,y1(t),'-g') xlabel('Time k') grid subplot(212),plot(mste) xlabel('Time k')

  13. Sigmoid2.m 函数文件 • function y=sigmoid2(x) • y=(1-exp(-x))/(1+exp(-x)) • end

More Related