# load "gnu/decay"
# weight decay
long = -1
short = 1 
load "gnu/square"

##################################
# weights in weight space
##################################

set xrange [1:10]
# ^ this is a bug fix for screwy gnuplot 
set autos xy 
# alpha = 0.01 
set nologs xy
set xlabel ; set ylabel ;   set key 20,-4; set yrange [-12:3]
set title "learning with weight decay, alpha=0.01"
set logs x
plot "wlwd01" u 4:1 t "w0" w l 1, "wlwd01" u 4:2 t "w1" w l 3, "wlwd01" u 4:3 t "w2" w l 4 
# pause long "learning with weight decay, alpha=0.01"
# set title "alpha = 0.01: weights v time (log)"
# replot
pause long "alpha=0.01 - weights versus time (log)"

set title "alpha=0.01 cf. alpha=0.0"
plot  "wl" u 4:1 t "w0" w l 2, "wl" u 4:2 t "w1" w l 2, "wl" u 4:3 t "w2" w l 2 ,"wlwd01" u 4:1 t "w0" w l 1, "wlwd01" u 4:2 t "w1" w l 3, "wlwd01" u 4:3 t "w2" w l 4 
pause long "weights versus time (log) [cf. alpha=0.0]"

##############################
# G and M versus time, alpha = 0.01
##############################
#set nologs xy 
#set xlabel ; set ylabel ; set xrange [1:10]
# ^ this is a bug fix for screwy gnuplot 
set autos xy ;  set key ; set yrange [0:7];  set xtics 0,10000,40000
## plot "wlwd01" u 4:5 t "G(w)" w l , "wlwd01" u 4:7 t "M(w)" w l
##pause long "G and M versus time, alpha = 0.01"
#set xtics 
#set logs x
# plot "wlwd01" u 4:5 t "G(w)" w l , "wlwd01" u 4:7 t "M(w)" w l
#pause long "G and M versus time, alpha = 0.01"
#
#
# weights in weight space
#
set nologs xy ; set key 1.5,2.3
set title "learning with alpha=0.01 cf. alpha=0"
set autos xy 
plot "wl" u 2:3  t "alpha = 0.0 " w l 1, "wlwd01" u 2:3 t "alpha = 0.01" w p 5 3 
pause long "learning in weight space: alpha = 0.01 cf. alpha = 0"


 set xrange [0:10] ; set yrange [0:10];  set nokey ; set xlabel ; set ylabel ; set nologs xy 
set title "alpha=0 - after 40000 iterations"
set arrow 1 from   2.4248,  2.5373 to   7.9269,  7.8144
plot 'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6 , ( - ( -27.895) - (   2.751) * x )/(  2.6385)  w l 1 , ( (       1) - ( -27.895) - (   2.751) * x )/(  2.6385)  w l 7 , ( - (       1) - ( -27.895) - (   2.751) * x )/(  2.6385)  w l 7 
pause long "alpha = 0.0 - Function performed after 40000 iterations"
set noarrow 1

set xrange [0:10] ; set yrange [0:10];  set nokey ; set xlabel ; set ylabel ; set nologs xy 
set title "alpha = 0.01"
set arrow 1 from   3.9292,  4.3159 to   6.3859,  5.9992
set title "solution with alpha=0.01"
plot  ( - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 1 , ( (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7 , ( - (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7, 'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6 
set noarrow 1 
pause long "solution found with alpha=0.01"


# set xrange [0:10] ; set yrange [0:10];  set nokey ; set xlabel ; set ylabel ; set nologs xy 
#set arrow 1 from   3.9292,  4.3159 to   6.3859,  5.9992
#plot  ( - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 1 , ( (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7 , ( - (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7, 'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6 
#pause long "function performed by solution found with alpha=0.01, again"

set title "alpha = 0.1"
# set title "increased weight decay to alpha=0.1"
set arrow 1 from   4.5028,  5.0585 to   5.8291,  5.2734
plot ( - ( -3.9809) - ( 0.66313) * x )/( 0.10748)  w l 1 , ( (       1) - ( -3.9809) - ( 0.66313) * x )/( 0.10748)  w l 7 , ( - (       1) - ( -3.9809) - ( 0.66313) * x )/( 0.10748)  w l 7 ,'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6 
pause long "increased weight decay to alpha=0.1"

set title "alpha = 1"
# set title "increased weight decay to alpha=1"
 set arrow 1 from   4.2267,  4.8409 to   5.0359,  4.4217
plot ( - (-0.90305) - ( 0.40458) * x )/( -0.2096)  w l 1 , ( (       1) - (-0.90305) - ( 0.40458) * x )/( -0.2096)  w l 7 , ( - (       1) - (-0.90305) - ( 0.40458) * x )/( -0.2096)  w l 7,'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6  
pause long "increased weight decay to alpha=1"

set title "back to alpha = 0.01"
 set xrange [0:10] ; set yrange [0:10];  set nokey ; set xlabel ; set ylabel ; set nologs xy 
# set title "function performed by solution found with alpha=0.01, again"
set arrow 1 from   3.9292,  4.3159 to   6.3859,  5.9992
plot  ( - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 1 , ( (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7 , ( - (       1) - ( -10.676) - (  1.2283) * x )/( 0.84162)  w l 7 , 'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6 
pause long "function performed by solution found with alpha=0.01, again"

set noarrow 1 
