liner.p used to make graphs of neuron zer-point

Damn, I got 0s and 1s mislabelled. +(Red squares are 1 in this case)
Now corrected.

module add octave
octave
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 100 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
w = zeros ( 3,1) ;
global wl=[]
# w=trainlog(w,200,0.01,0.0) ; # 0.02 was too big a rate
w=trainlog(w,40000,0.01,0.0) ; # 0.02 was too big a rate
# w=trainlog(w,10000,0.017,0.0) ;
# w=trainlog(w,10000,0.027,0.0) ;
save wl wl

# learning with weight decay 
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 100 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
w = zeros ( 3,1) ;
global wl=[]
w=trainlog(w,40000,0.01,0.01) ; # 
save wlwd01 wl

REDO WTIH too much WD
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 100 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
w = zeros ( 3,1) ;
global wl=[] ;
w=trainlog(w,40000,0.01,0.1) ; # 
save wlwd wl

actually the above is still pretty reasonable
REDO WTIH too much WD
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 100 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
w = zeros ( 3,1) ;
global wl=[] ;
w=trainlog(w,40000,0.01,1) ; # 
save wlwd1 wl

OK, this really is too much


The original demo used a varying eta that started small (0.00x) 
and increased to 0.017, then 0.027.
Now I am using a constant rate 0.01 



###################################################################
 Next task: the case of an overlapping data set
###################################################################


then

###################################################################
 Langevin method
###################################################################
A first stab: 
module add octave
octave
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 100 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
w = zeros ( 3,1) ;
global wl=[]
w=langevin(w,200,0.01,0.01) ; # 0.02 was too big a rate
save wlang wl
w=langevin(w,40000,0.01,0.01) ; # 0.02 was too big a rate

Nice pics!

plot "wlang" u 2:3 w l,"wl" u 2:3 w l,"wlwd01" u 2:3 w p 
!head -100 wlang > wlang.1.100
!
gnuplot> !tail -255 wlang > wlang.250.505
!
plot "wlang" u 2:3 w l,"wl" u 2:3 w l,"wlwd01" u 2:3 w p, "wlang.1.100" u 2:3 w l, "wlang.250.505" u 2:3 w l
plot "wlang" u 2:3 w p,"wl" u 2:3 w l,"wlwd01" u 2:3 w l, "wlang.1.100" u 2:3 w p, "wlang.250.505" u 2:3 w p

interesting. Much hopping about at -45 degrees.

Is this for real, or an artefact of too-big steps?

try smaller eta
w=langevin(w,200,0.0025,0.01) ; # 0.02 was too big a rate
save wlang0025 wl
w=langevin(w,40000,0.0025,0.01) ; # 0.02 was too big a rate
save wlang0025 wl

This smaller step size gives results that look similar.

global dT0 = 1;   # frequency of writing
global T0 = 2000 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
global accepts = 0 ; 
global rejects = 0 ; 
w = zeros ( 3,1) ;
global wl=[]
w=langevinmc(w,1000,0.01,0.01) ; # 
save wlangmc wl
w=langevinmc(w,40000,0.01,0.01) ; # 
save wlangmc wl

OK, that looks like pretty frequent rejections? 
No, I found my bug and now the acceptance rate has gone up a lot.
plot "wlangmc" u 4:1 t "w0" w l,"wlangmc" u 4:2 t "w1" w l,"wlangmc" u 4:3 t "w2" w l
set xrange [0:1000]
replot "wl" u 4:1 t "w0" w l,"wl" u 4:2 t "w1" w l,"wl" u 4:3 t "w2" w l
replot "wlwd01" u 4:1 t "w0" w l,"wlwd01" u 4:2 t "w1" w l,"wlwd01" u 4:3 t "w2" w l


plot "wlangmc" u 2:3 w linesp
replot "wlwd01" u 2:3 w l

select states from 10000 onwards.
tail saved in wlangmc.10000.41000
every.p 10 1 wlangmc.10000.41000 > wlangmc.every1000
liner.p < wlangmc.every1000 > langmc.gnu
liner.p post=1 < wlangmc.every1000 > langmcps.gnu2

#############################
############ This is a beautiful demo!
#############################
load "langmc.gnu" 
#
# these are without and with nice arrows: 
load "langmcps.gnu" 
load "langmcps.gnu2" 

Now to make the average:

averager.p < wlangmc.every1000 > makeavg.p
makeavg.p NB=21 > langavg.dat


##################################
# most plot commands have been put into 
# load "READgnu"
##################################
see also DEMO and DEMOLANG and langmc.gnu

octave:116> accepts
accepts = 38299
octave:117> rejects
rejects = 2701
octave:118> 38299 + 2701
ans = 41000
octave:119> 38299 / 41000
ans = 0.93412

OK, can we do a Gaussian job? 
have written hessianM(w)

load -force data/toy/dat01
global fprime ; 
global fpx ; 
global alphag = 0.01 ; 
w = zeros ( 3,1) ;
A = hessianM(w) ; 

w = [[ -10.675967811201];[ 1.22833511041007 ];[0.841624676434437 ]]
A = hessianM(w) ; 
gives
A =

   0.90650   4.78206   4.32100
   4.78206  26.91783  22.59040
   4.32100  22.59040  21.87942

global AI = inv(A)
AI =

   40.764235   -3.637496   -4.294893
   -3.637496    0.602875    0.095909
   -4.294893    0.095909    0.794884


global lo=[] ;
marg(w) ;
ok, that writes to margo ok. looks over moderated?
AIsub = [ 0.602875    0.095909 ; 0.095909    0.794884 ]

AISI = inv(AIsub) 
   1.69118  -0.20405
  -0.20405   1.28267

OK, go to weight space and  plot contours
AIsubSQRT = AIsub**(1/2)
AIsubSQRT =

  0.774308  0.057637
  0.057637  0.889698
I put these by hand into gnuplot ellipses




----------------
HMC
----------------
load -force data/toy/dat01
global dT0 = 1;   # frequency of writing
global T0 = 2000 ; # time at which to write less frequently
global dT = 100;  # frequency of writing thereafter
global logtime = 1; # column of log matrix 
global T = 1 ;
global accepts = 0 ; 
global rejects = 0 ; 
global Taumax = 100 ; #
global grads = 0 ; 
w = zeros ( 3,1) ;
global wl=[]
w=hmc(w,100,0.01,0.01) ; # 
global dT = 1;  # frequency of writing thereafter
w=hmc(w,300,0.01,0.01) ; # 
save whmc wl

octave:104> accepts
accepts = 96
octave:105> rejects
rejects = 4
octave:109> accepts
accepts = 371
octave:110> rejects
rejects = 29
octave:111> grads
grads = 60578

that's 8% rejection
