Page 43 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 43

1. Artificial Intelligence                                        31

               0.2225    1.0172
               0.2426    1.0483
               0.3244    1.1747

           After rounding OUTPUT exactly matches with the Desired Output as shown
           below
                0     0
                0     1
                0     1
                0     1
                0     1
                0     1
                0     1
                0     1


           4.4      M-program for Training the Artificial Neural
                    Network for the Problem Proposed in the Previous
                    Section

           ___________________________________________________________
           anngv.m
            SSE=[ ];  INDEX=[ ];
            INPUT=[0 0 0;0 0 1;0 1 0;0 1 1;1 0 0;1 0 1;1 1 0;1 1 1];
            DOUTPUT=[0 0;0 1;0 1 ;0 1;0 1;0 1;0 1 ;1 1];
            W1=rand(3,1);W2=rand(1,2);
             B1=rand(1,1);  B2=rand(1,2);
              for i=1:1:1200
                       for j=1:1:8
                H=logsiggv(INPUT*W1+repmat(B1,[8 1]));
                OUTPUT=H*W2 +repmat(B2,[8 1]);
                ERR_HO=DOUTPUT - OUTPUT;
                ERR_IH=H.*(1-H).*(sum(ERR_HO')');
                lr_ho=0.01;
                lr_ih=0.01;
                W2(1,1)=W2(1,1)+ERR_HO(j,1)*H(j,1)*lr_ho;
                W2(1,2)=W2(1,2)+ERR_HO(j,2)*H(j,1)*lr_ho;
                W1(1,1)=W1(1,1)+ERR_IH(j,1)*INPUT(j,1)*lr_ih;
                W1(2,1)=W1(2,1)+ERR_IH(j,1)*INPUT(j,2)*lr_ih;
                W1(3,1)=W1(3,1)+ERR_IH(j,1)*INPUT(j,3)*lr_ih;
                B1=B1+ERR_IH(j,1)*lr_ih;
                B2(1,1)=B2(1,1)+ERR_HO(j,1)*lr_ho;
   38   39   40   41   42   43   44   45   46   47   48