loadNet ("win17-20relu-10relu-6relu-3softmax.net")
#loadNet ("best2.net")
loadPattern ("/home/reczko/snns/tra.pat")
loadPattern ("/home/reczko/snns/val.pat")
resfile := "test2.res"
ep := 0
done := 0
nonbest := 0

setInitFunc( "Randomize_Weights", 0.05, -0.05)
#initNet ()
setLearnFunc( "RpropMAP", 0.001, 0.05, 6, 50, 2)
repeat

 
 setPattern ("/home/reczko/snns/tra.pat")
 for i := 1 to 2 do
  trainNet ()
  print(SSE)
 endfor

 saveNet("test2.net")
 loadNet("test2.net")
 setPattern ("/home/reczko/snns/val.pat")
#testNet ()
 saveResult (resfile, 1, PAT, FALSE, TRUE, "create")
 command := "/home/reczko/snns/SNNSv4.3/tools/sources/analyze -s -e WTA -i " + resfile + " | awk -f /home/reczko/snns/SNNSv4.3/tools/sources/analyze.gawk"
 execute(command, w, r, u, e)
 print("ep: ",ep, " wrong: ",w, " right: ",r, " unknown: ",u, " error: ",e)

 if (ep==0) then bestr := r
 else
   if (r>bestr) then
     bestr := r
     saveNet("best2.net")
     execute("cp test2.res best2.res")
     nonbest := 0
   else
    nonbest := nonbest + 1
  endif
 endif
 if ( (ep > 4) && ( nonbest > 80 ) ) then
   done := 1
 endif
 ep := ep + 1
until ((done == 1) or (SIGNAL == 2))
if (done == 1) then execute("rm test2.res") endif
print("best right: ",lr)

