Make.Algodiff
include Owl_algodiff_core_sig.Sig
module A : Owl_types_ndarray_algodiff.Sig
iteratively get primal component of DF or DR type until the component itself is not DF/DR
val shape : t -> int array
get the shape of primal' value of input
val is_float : t -> bool
check if input is of float value; if input is of type DF/DR, check its primal' value
val is_arr : t -> bool
check if input is of ndarray value; if input is of type DF/DR, check its primal' value
val row_num : t -> int
get the shape of primal' value of input; and then get the first dimension
val col_num : t -> int
get the shape of primal' value of input; and then get the second dimension
val numel : t -> int
for ndarray type input, return its total number of elements.
if primal' value of input is ndarray, copy its value in a new AD type ndarray
val pack_flt : float -> t
convert from float
type to t
type.
val _f : float -> t
A shortcut function for F A.(float_to_elt x)
.
val unpack_flt : t -> float
convert from t
type to float
type.
val deep_info : t -> string
val type_info : t -> string
val error_uniop : string -> t -> 'a
make_forward p t i
construct a forward algodiff data type DF, consisting of primal p
, tangent t
, and tag i
.
make_reverse p i
construct a reverse algodiff data type DR, consisting of primal, adjoint, op, fanout, tag, and tracker.
reverse_prop f x
performs reverse propagation for function f
using the output value x
.
diff f x
returns the exat derivative of a function f : scalar -> scalar
at point x
. Simply calling diff f
will return its derivative function g
of the same type, i.e. g : scalar -> scalar
.
Keep calling this function will give you higher-order derivatives of f
, i.e. f |> diff |> diff |> diff |> ...
jacobian of f
: (vector -> vector) at x
, both x
and y
are row vectors.
jacobian vector product of f
: (vector -> vector) at x
along v
, forward ad. Namely, it calcultes (jacobian x) v
similar to jacobianv'
, but return (f x, jacobianv f x v)
transposed jacobian vector product of f : (vector -> vector)
at x
along v
, backward ad. Namely, it calculates transpose ((jacobianv f x v))
.
similar to jacobianTv
, but return (f x, transpose (jacobianv f x v))
hessian vector product of f
: (scalar -> scalar) at x
along v
. Namely, it calculates (hessian x) v
.
include Owl_algodiff_ops_sig.Sig
with type t := t
and type elt := A.elt
and type arr := A.arr
and type op := op
module Maths : sig ... end
module Linalg : sig ... end
module NN : sig ... end
module Mat : sig ... end
module Arr : sig ... end
include Owl_algodiff_graph_convert_sig.Sig with type t := t
val to_trace : t list -> string
to_trace [t0; t1; ...]
outputs the trace of computation graph on the terminal in a human-readable format.
val to_dot : t list -> string
to_dot [t0; t1; ...]
outputs the trace of computation graph in the dot file format which you can use other tools further visualisation, such as Graphviz.
val pp_num : Stdlib.Format.formatter -> t -> unit
pp_num t
pretty prints the abstract number used in Algodiff
.