Module Adam.Make
Parameters
AD : Owl_algodiff_generic_sig.Sig with type AD.A.elt = float
P : Owl_opt.Prms.PT
Signature
type fv
= AD.t
objective function value type
type prm
= AD.t
paramter type
type status
= Owl_opt__.Status.t
=
|
Continue of float
|
Stop of float
optimization status
type stop
= float -> state -> bool
stopping criterion function type
val iter : state -> int
iter s
returns the current iteration number of states
val prev_fv : state -> float
prev_fv s
returns the last objective function value of states
val fv_hist : state -> float list
fv_hist s
returns the history of the objective function values of states
up to the last objective function value (i.e.,prev_f s
is the same asList.hd (fv_hist s)
)
val init : ?beta1:float -> ?beta2:float -> ?eps:float -> lr:Owl_opt.Lr.t -> prms0:prms -> unit -> state
init ?(beta1=0.99) ?(beta2=0.999) ?(eps=1E-8) ~lr ~prms0 ()
initialises and returns optimisation states
with initial parmatersprms0
. The hyperparamtersbeta1
,beta2
, andeps
are defined here.
val stop : float -> state -> bool
stop fv s
is the default stopping criterion, which prints out the iteration and objective function value at each optimisation iteration and terminates when the objective function value goes below 1E-4
val min_step : ?stop:stop -> f:f -> state -> status
min_step ?(stop=stop) ~f s
computes the function valuefv
of optimization states
with parameters (i.e.,f (iter s) (prms s)
returnsfv
). If the stopping criterion is reached (i.e.stop fv s
istrue
), then returnStop fv
and no optimization is performed. Otherwise, minizief
by updating the parameters ofs
one step (in place) according to Adam and returnsContinue fv
. Here,stop fv s
is a callback function that can be used to specify the termination criterion and print out intermediate function values.
val max_step : ?stop:stop -> f:f -> state -> status
max_step ?(stop=stop) ~f ~lr
is similar tomin_step
but maximises f.