package owl-base

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include Owl_algodiff_generic_sig.Sig
Type definition
type arr

General ndarray type

type elt

Scalar type

type trace_op

Trace type

type t =
  1. | F of float
  2. | Arr of arr
  3. | DF of t * t * int
  4. | DR of t * t ref * trace_op * int ref * int
    (*

    Abstract number type

    *)
Supported Maths functions
module Maths : sig ... end
module Mat : sig ... end
module Arr : sig ... end
Core functions
val diff : (t -> t) -> t -> t

``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 |> ...``

val diff' : (t -> t) -> t -> t * t

similar to ``diff``, but return ``(f x, diff f x)``.

val grad : (t -> t) -> t -> t

gradient of ``f`` : (vector -> scalar) at ``x``, reverse ad.

val grad' : (t -> t) -> t -> t * t

similar to ``grad``, but return ``(f x, grad f x)``.

val jacobian : (t -> t) -> t -> t

jacobian of ``f`` : (vector -> vector) at ``x``, both ``x`` and ``y`` are row vectors.

val jacobian' : (t -> t) -> t -> t * t

similar to ``jacobian``, but return ``(f x, jacobian f x)``

val jacobianv : (t -> t) -> t -> t -> t

jacobian vector product of ``f`` : (vector -> vector) at ``x`` along ``v``, forward ad. Namely, it calcultes ``(jacobian x) v``

val jacobianv' : (t -> t) -> t -> t -> t * t

similar to ``jacobianv'``, but return ``(f x, jacobianv f x v)``

val jacobianTv : (t -> t) -> t -> t -> t

transposed jacobian vector product of ``f : (vector -> vector)`` at ``x`` along ``v``, backward ad. Namely, it calculates ``transpose ((jacobianv f x v))``.

val jacobianTv' : (t -> t) -> t -> t -> t * t

similar to ``jacobianTv``, but return ``(f x, transpose (jacobianv f x v))``

val hessian : (t -> t) -> t -> t

hessian of ``f`` : (scalar -> scalar) at ``x``.

val hessian' : (t -> t) -> t -> t * t

simiarl to ``hessian``, but return ``(f x, hessian f x)``

val hessianv : (t -> t) -> t -> t -> t

hessian vector product of ``f`` : (scalar -> scalar) at ``x`` along ``v``. Namely, it calculates ``(hessian x) v``.

val hessianv' : (t -> t) -> t -> t -> t * t

similar to ``hessianv``, but return ``(f x, hessianv f x v)``.

val laplacian : (t -> t) -> t -> t

laplacian of ``f : (scalar -> scalar)`` at ``x``.

val laplacian' : (t -> t) -> t -> t * t

simiar to ``laplacian``, but return ``(f x, laplacian f x)``.

val gradhessian : (t -> t) -> t -> t * t

return ``(grad f x, hessian f x)``, ``f : (scalar -> scalar)``

val gradhessian' : (t -> t) -> t -> t * t * t

return ``(f x, grad f x, hessian f x)``

val gradhessianv : (t -> t) -> t -> t -> t * t

return ``(grad f x v, hessian f x v)``

val gradhessianv' : (t -> t) -> t -> t -> t * t * t

return ``(f x, grad f x v, hessian f x v)``

Low-level functions
val pack_flt : elt -> t

TODO

val unpack_flt : t -> elt

TODO

val pack_arr : arr -> t

TODO

val unpack_arr : t -> arr

TODO

val tag : unit -> int

TODO

val primal : t -> t

TODO

val primal' : t -> t

TODO

val adjval : t -> t

TODO

val adjref : t -> t ref

TODO

val tangent : t -> t

TODO

val make_forward : t -> t -> int -> t

TODO

val make_reverse : t -> int -> t

TODO

val reverse_prop : t -> t -> unit

TODO

val type_info : t -> string

TODO

val shape : t -> int array

TODO

val copy_primal' : t -> t

TODO

val clip_by_value : amin:elt -> amax:elt -> t -> t
val clip_by_l2norm : elt -> t -> t
Helper functions
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 : Format.formatter -> t -> unit

``pp_num t`` pretty prints the abstract number used in ``Algodiff``.

Init neuron
module Init : sig ... end
Input neuron
module Input : sig ... end
Activation neuron
module Activation : sig ... end
Linear neuron
module Linear : sig ... end
LinearNoBias neuron
module LinearNoBias : sig ... end
Recurrent neuron
module Recurrent : sig ... end
LSTM neuron
module LSTM : sig ... end
GRU neuron
module GRU : sig ... end
Conv1D neuron
module Conv1D : sig ... end
TransposeConv1D neuron
module TransposeConv1D : sig ... end
Conv2D neuron
module Conv2D : sig ... end
TransposeConv2D neuron
module TransposeConv2D : sig ... end
Conv3D neuron
module Conv3D : sig ... end
TransposeConv3D neuron
module TransposeConv3D : sig ... end
FullyConnected neuron
module FullyConnected : sig ... end
MaxPool1D neuron
module MaxPool1D : sig ... end
MaxPool2D neuron
module MaxPool2D : sig ... end
AvgPool1D neuron
module AvgPool1D : sig ... end
AvgPool2D neuron
module AvgPool2D : sig ... end
GlobalMaxPool1D neuron
module GlobalMaxPool1D : sig ... end
GlobalMaxPool2D neuron
module GlobalMaxPool2D : sig ... end
GlobalAvgPool1D neuron
module GlobalAvgPool1D : sig ... end
GlobalAvgPool2D neuron
module GlobalAvgPool2D : sig ... end
UpSampling1D neuron
module UpSampling1D : sig ... end
UpSampling2D neuron
module UpSampling2D : sig ... end
UpSampling3D neuron
module UpSampling3D : sig ... end
Padding1D neuron
module Padding1D : sig ... end
Padding2D neuron
module Padding2D : sig ... end
Padding3D neuron
module Padding3D : sig ... end
Lambda neuron
module Lambda : sig ... end
Dropout neuron
module Dropout : sig ... end
Reshape neuron
module Reshape : sig ... end
Flatten neuron
module Flatten : sig ... end
Add neuron
module Add : sig ... end
Mul neuron
module Mul : sig ... end
Dot neuron
module Dot : sig ... end
Max neuron
module Max : sig ... end
Average neuron
module Average : sig ... end
Concatenate neuron
module Concatenate : sig ... end
Normalisation neuron
module Normalisation : sig ... end
GaussianNoise neuron
module GaussianNoise : sig ... end
GaussianDropout neuron
module GaussianDropout : sig ... end
AlphaDropout neuron
module AlphaDropout : sig ... end
Embedding neuron
module Embedding : sig ... end
Masking neuron
module Masking : sig ... end
Core functions
type neuron =
  1. | Input of Input.neuron_typ
  2. | Linear of Linear.neuron_typ
  3. | LinearNoBias of LinearNoBias.neuron_typ
  4. | Embedding of Embedding.neuron_typ
  5. | LSTM of LSTM.neuron_typ
  6. | GRU of GRU.neuron_typ
  7. | Recurrent of Recurrent.neuron_typ
  8. | Conv1D of Conv1D.neuron_typ
  9. | Conv2D of Conv2D.neuron_typ
  10. | Conv3D of Conv3D.neuron_typ
  11. | TransposeConv1D of TransposeConv1D.neuron_typ
  12. | TransposeConv2D of TransposeConv2D.neuron_typ
  13. | TransposeConv3D of TransposeConv3D.neuron_typ
  14. | FullyConnected of FullyConnected.neuron_typ
  15. | MaxPool1D of MaxPool1D.neuron_typ
  16. | MaxPool2D of MaxPool2D.neuron_typ
  17. | AvgPool1D of AvgPool1D.neuron_typ
  18. | AvgPool2D of AvgPool2D.neuron_typ
  19. | GlobalMaxPool1D of GlobalMaxPool1D.neuron_typ
  20. | GlobalMaxPool2D of GlobalMaxPool2D.neuron_typ
  21. | GlobalAvgPool1D of GlobalAvgPool1D.neuron_typ
  22. | GlobalAvgPool2D of GlobalAvgPool2D.neuron_typ
  23. | Dropout of Dropout.neuron_typ
  24. | Reshape of Reshape.neuron_typ
  25. | Flatten of Flatten.neuron_typ
  26. | Lambda of Lambda.neuron_typ
  27. | Activation of Activation.neuron_typ
  28. | GaussianNoise of GaussianNoise.neuron_typ
  29. | GaussianDropout of GaussianDropout.neuron_typ
  30. | AlphaDropout of AlphaDropout.neuron_typ
  31. | Normalisation of Normalisation.neuron_typ
  32. | Add of Add.neuron_typ
  33. | Mul of Mul.neuron_typ
  34. | Dot of Dot.neuron_typ
  35. | Max of Max.neuron_typ
  36. | Average of Average.neuron_typ
  37. | Concatenate of Concatenate.neuron_typ
    (*

    Types of neuron.

    *)
val get_in_out_shape : neuron -> int array * int array

Get both input and output shapes of a neuron.

val get_in_shape : neuron -> int array

Get the input shape of a neuron.

val get_out_shape : neuron -> int array

Get the output shape of a neuron.

val connect : int array array -> neuron -> unit

Connect this neuron to others in a neural network.

val init : neuron -> unit

Initialise the neuron and its parameters.

val reset : neuron -> unit

Reset the parameters in a neuron.

val mktag : int -> neuron -> unit

Tag the neuron, used by ``Algodiff`` module.

val mkpar : neuron -> t array

Assemble all the parameters in an array, used by ``Optimise`` module.

val mkpri : neuron -> t array

Assemble all the primial values in an array, used by ``Optimise`` module.

val mkadj : neuron -> t array

Assemble all the adjacent values in an array, used by ``Optimise`` module.

val update : neuron -> t array -> unit

Update parameters in a neuron, used by ``Optimise`` module.

val copy : neuron -> neuron

Make a deep copy of the neuron and its parameters.

val run : t array -> neuron -> t

Execute the computation in this neuron.

val to_string : neuron -> string

Convert the neuron to its string representation. The string is often a summary of the parameters defined in the neuron.

val to_name : neuron -> string

Return the name of the neuron.