Module Autograd

Automatic differentiation and backward propagation.

type t = {
  1. mutable value : float;
    (*

    scalar value of this node calculated during forward pass

    *)
  2. mutable grad : float;
    (*

    derivative of the loss w.r.t. this node, calculated in backward pass

    *)
  3. children : t list;
    (*

    children of this node in the computation graph

    *)
  4. local_grads : float list;
    (*

    local derivative of this node w.r.t. its children

    *)
  5. mutable visited : bool;
    (*

    whether the value was already visited during backprop

    *)
}

A value that can be backpropagated.

val value : t -> float

Get value.

val grad : t -> float

Get gradient.

val make : float -> t list -> float list -> t
val const : float -> t

Constant value.

val add : t -> t -> t

Addition.

val sub : t -> t -> t

Subtraction.

val neg : t -> t

Negation.

val cmul : float -> t -> t

Multiplication by a constant.

val mul : t -> t -> t

Multiplication.

val div : t -> t -> t

Division.

val exp : t -> t

Exponentiation.

val powc : t -> float -> t

Power by a constant.

val log : t -> t

Natural logarithm.

val relu : t -> t

Rectified linear unit.

val sigmoid : t -> t

Sigmoid function.

val backward : t -> unit

Perform backward propagation.

module Infix : sig ... end

Infix notations.

module Vector : sig ... end

Vectors.

module Matrix : sig ... end

Matrices.