Owl Opt LBFGS Library
The entry point of this library is Owl_opt_lbfgs
. The workflow is similar to that described in Owl Opt.
This library is built ontop of L-BFGS-ocaml.
Installation
dune build @install
dune install
Example
module Prms = struct
type 'a t = {a: 'a; b: 'a} [@@deriving prms]
end
(* make an Lbfgs optimisation module for the parameter definition Prms *)
module O = Owl_opt_lbfgs.D.Make (Prms)
(* define the objective function *)
let f _ prms = Owl.Algodiff.D.Maths.(l2norm' (y - ((prms.a *@ x) + prms.b)))
(* define initial parameters *)
let prms0 = {a = Owl.Algodiff.D.Mat.gaussian 5 5; b = Owl.Algodiff.D.gaussian 5 1}
(* initialise an optimisation session *)
let s = O.init ~prms0 ()
(* define stopping criteria: stop when function value is smaller than 1E-4 *)
let stop fv s = fv < 1E-4
(* minimise objective function f *)
let fv = O.min ~f s
(* final prms *)
let prms = O.prms s
Important modules
- Single-precision
Owl_opt_lbfgs.S.Make
- Double-precision
Owl_opt_lbfgs.D.Make