Module Gd_s.Make

Parameters

Signature

type 'a t

user-defined record type

type fv = Owl.Algodiff.S.t

objective function value type

type prm = Owl.Algodiff.S.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 number of iterations for optimisation 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 : prms0:prms -> lr:Owl_opt.Lr.t -> unit -> state

init ~prms0 ~lr () initialises and returns optimisation state for initial parmaters prms0 and learning rate lr

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-3

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) via gradient descent 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 gradient descent 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.