You are on page 1of 6

function BackPropAlgo(Input, Output) %STEP 1 : Normaliz %"! cking #! t! r t! t!

Input Input$ n %$ to & normaliz % or not

if (ma'(Input(:))( 1 )) ma'(Input(:))*+1) %N % to normaliz

Norm,Input - Input . ma'(Input(:))/ l$ Norm,Input - Input/ n% %"! cking 0! t! r t! Output$ n %$ to & normaliz % or not

if(ma'(Output(:)) ( 1 )) ma'(Output(:))*+1) %N % to normaliz

Norm,Output - Output . ma'(Output(:))/ l$ Norm,Output - Output/ n% %A$$igning t! m - 2/ %3in% t! $iz of Input an% Output 4 ctor$ num& r of !i%% n n uron$ in !i%% n la1 r

5l,&6 - $iz (Input)/ 5n,a6 - $iz (Output)/ %Initializ t! # ig!t matric $ #it! ran%om # ig!t$

4 - ran%(l,m)/ % 0 ig!t matri' from Input to 7i%% n 0 - ran%(m,n)/ % 0 ig!t matri' from 7i%% n to Output %S tting count to z ro, to kno# t! count - 8/ num& r of it ration$

%"alling function for training t! 5 rror4alu %"! cking if

n ural n t#ork

% lta,4 % lta,06 - trainN uralN t(Norm,Input,Norm,Output,4,0)/ rror 9alu i$ gr at r t!an 8:1: If 1 $, # t! t!r $!ol% 9alu n % to train t!

%n t#ork again: ;$ r can % ci% #!il rror4alu * 8:8<

%incr m nting count count - count = 1/ %Stor t! rror 9alu into a matri' to plot t! grap!

Error,>at(count)- rror4alu / %"!ang t! # ig!t m tri' 4 an% 0 &1 a%%ing % lta 9alu $ to t! m

0-0=% lta,0/ 4-4=% lta,4/ %"alling t! %No# # count 5 rror4alu % lta,4 % lta,06-trainN uralN t(Norm,Input,Norm,Output,4,0,% lta,4,% lta,0)/ n% %T!i$ co% #ill & ( 8:8< to kno# t! num& r of it ration ' cut % #! n t! rror 9alu i$ l $$ t!an 8:1 !a9 function #it! anot! r o9 rloa%: % lta 9alu $ a$ # ll:

if rror4alu

%Incr m nting count 9aria&l count-count=1/ %Storing rror 9alu

into matri' for plotting t!

grap!

Error,>at(count)- rror4alu / n% %"alculating rror rat

Error,?at -$um(Error,>at).count/ figur / %$ tting 1 9alu 1-51:count6/ %Plotting grap! plot(1, Error,>at)/ n% 3unction to train t! n t#ork for plotting grap!

%"r at % B1 : Anoop:4:S @ A k$!mi B B %"r at % On : 1C+8D+281E %F $cription : 3unction to train t! function 5 rror4alu % lta,4, % lta,0) n t#ork

% lta,4 % lta,06 - trainN uralN t(Input, Output, 4, 0,

%3unction for calculation ($t p$ G + 1H) %To train t! N ural N t#ork Output of Input Aa1 r

%"alculating t!

%No computation ! r : %Output of Input Aa1 r i$ $am Output,of,InputAa1 r - Input/ %"alculating Input of t! %7 r # n 7i%% n Aa1 r Output of t! Input Aa1 r #it! t! + a$ t! Input of Input Aa1 r

% to multipl1 t!

%$1naptic # ig!t: T!at # ig!t i$ in t!

matri' 4:

Input,of,7i%% nAa1 r - 4I J Output,of,InputAa1 r/ %"alculat t! $iz of Input to 7i%% n Aa1 r

5m n6 - $iz (Input,of,7i%% nAa1 r)/

%No#, #

!a9

to calculat n % to u$

t!

Output of t!

7i%% n Aa1 r

%3or t!at, #

Sigmoi%al 3unction

Output,of,7i%% nAa1 r - 1:.(1= 'p(+Input,of,7i%% nAa1 r))/

%"alculating Input to Output Aa1 r %7 r # n % to multipl1 t! Output of t! 7i%% n Aa1 r #it! t! +

%$1naptic # ig!t: T!at # ig!t i$ in t!

matri' 0

Input,of,OutputAa1 r - 0IJOutput,of,7i%% nAa1 r/ %"l ar 9ara&l $ cl ar m n/ %"alculat t! $iz of Input of Output Aa1 r

5m n6 - $iz (Input,of,OutputAa1 r)/

%No#, #

!a9

to calculat n % to u$

t!

Output of t!

Output Aa1 r

%3or t!at, #

Sigmoi%al 3unction

Output,of,OutputAa1 r - 1:.(1= 'p(+Input,of,OutputAa1 r))/

%No# #

% to calculat

t!

Error u$ing ?oot > an SKuar

m t!o%

%iff r nc $Kuar

- Output + Output,of,OutputAa1 r/

- %iff r nc :J%iff r nc / - $Krt($um($Kuar (:)))/ t! matri' I%I #it! r $p ct to t! m an% n % $ir % output

rror4alu %"alculat %"l ar t! cl ar m n

9aria&l

5n a6 - $iz (Output)/ for i - 1 : n for L - 1 : a

%(i,L) -(Output(i,L)+ Output,of,OutputAa1 r(i,L))JOutput,of,OutputAa1 r(i,L)J(1+ Output,of,OutputAa1 r(i,L))/ n% n% %No#, calculat t! M matri'

M - Output,of,7i%% nAa1 r J %/ %STEP 11 %"! cking num& r of argum nt$: 0 %On t! %So # %& $am fir$t it ration, # !a9 to initializ ar u$ing function o9 rloa%ing % lta 4 an% % lta 0 $iz of % lta 4 an% % lta 0 #ill

%onIt !a9 #it! z ro: T!

a$ t!at of 4 an% 0 matri' r $p cti9 l1 (nargin + no of argum nt$)

if nargin -- G % lta,0-z ro$($iz (0))/ % lta,4-z ro$($iz (4))/ n% %Initializing tta #it! 8:H an% alp!a #it! 1

tta-8:H/alp!a-1/ %"alculating % lta 0 % lta,0- alp!a:J% lta,0 = %STEP 1E %"alculating rror - 0J%/ %"alculating %J cl ar m n 5m n6 - $iz ( rror)/ for i - 1 : m for L - 1 :n rror matri' tta:JM/%STEP 12

%,$tar(i,L)- rror(i,L)JOutput,of,7i%% nAa1 r(i,L)J(1+ Output,of,7i%% nAa1 r(i,L))/ n% n% %No# fin% matri', N (Input J tran$po$ N - Input J %,$tarI/ %STEP 1G %"alculating % lta 4 % lta,4-alp!aJ% lta,4= ttaJN/ n% of %,$tar)

I found some mistakes: Line 117 contains HTML code Line 193 is lacking matrix indizes: Output of OutputLa!er " 1#$1%exp$&Input of OutputLa!er$i'()))* Output of OutputLa!er$i'() " 1#$1%exp$&Input of OutputLa!er$i'()))*

You might also like