Module Adam.Make

Parameters

Signature

type 'a t

user-defined record type

type fv = AD.t

objective function value type

type prm = AD.t

paramter type

type prms = prm t

user-defined paramter record type

type f = int -> prms -> fv

objective function type

type state

internal state

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 state s

val prms : state -> prms

prms s returns the optimisation parameters of state s

val prev_fv : state -> float

prev_fv s returns the last objective function value of state s

val fv_hist : state -> float list

fv_hist s returns the history of the objective function values of state s up to the last objective function value (i.e., prev_f s is the same as List.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 state s with initial parmaters prms0. The hyperparamters beta1, beta2, and eps 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 value fv of optimization state s with parameters (i.e., f (iter s) (prms s) returns fv). If the stopping criterion is reached (i.e. stop fv s is true), then return Stop fv and no optimization is performed. Otherwise, minizie f by updating the parameters of s one step (in place) according to Adam and returns Continue 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 to min_step but maximises f.

val min : ?⁠stop:stop -> f:f -> state -> float

min ?(stop=stop) ~f status iteratively minimises f using Adam until the stopping criterion is reached (i.e., stop fv s returns true), then returns the final function value fv. See min_step for details on stop.

val max : ?⁠stop:stop -> f:f -> state -> float

max ?(stop=stop) ~f ~lr s is similar to min but maximises f.