⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getw.m

📁 BP神经网络
💻 M
字号:
%trainning the BP network, weight
clear ;
clc;
nh=14;       %the number of hidden unit
d=64;         %the number of input unit
k=10;        %the number of output unit
wji=unifrnd(-1/sqrt(d),1/sqrt(d),nh,d);              %wji is 14*64
wkj=unifrnd(-1/sqrt(nh),1/sqrt(nh),k,nh);            %wkj is 10*14
it=0.1;             %learning rate
ct=0.6;              % error
r=0.9;
sample=vector(0);
jj=[];
erms=2;
while erms>ct
    nrnd=unidrnd(80,1,80);              %get the randon number 
    p=1;
    e=0;
    bji=0;
    bkj=0;
              while p<81
                 x=sample(:,nrnd(p));              %x is 64*1
                 t=teach(nrnd(p));                 %t is 1*10
                 netj=wji*x;                    %netj is 14*1
                 yj=f(netj);                    %yj is 14*1
                 netk=wkj*yj;                   %netk is 10*1
                 z=f(netk);                     %z is 1*10
                % z=round(z);
                 sk=(t'-z).*df(netk);           %sk is 10*1
                 bkj=it*sk*yj'*(1-r)+r*bkj;
                 wkj=wkj+bkj;             %
                 sj=df(netj).*(wkj'*sk);        %sj is 14*1
                 bji=it*sj*x'*(1-r)+r*bji;
                 wji=wji+bji;
                 j=(t'-z)'*(t'-z);
                 e=e+j;
                 p=p+1;
             end
        erms =sqrt(e/80);
         jj=[jj,erms];
     end
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     plot(jj);
     title('training process');
     xlabel('with momentum ');
     ylabel('error');
      save wkj2(2).dat wkj -ascii
     save wji2(2).dat wji -ascii
     


   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -