Module Net.Layer

Layers of a net.

type t = {
  1. inputs : int;
    (*

    Number of inputs.

    *)
  2. outputs : int;
    (*

    Number of outputs.

    *)
  3. forward : Vector.t -> Vector.t;
    (*

    Forward computation.

    *)
  4. backward : Vector.t -> Vector.t -> Vector.t;
    (*

    Backward computation: given the input and the output gradient, update the weights and return the new gradient.

    *)
}

A layer.

val src : t -> int
val tgt : t -> int
val linear : ?regularization:float -> rate:float -> Matrix.t Stdlib.ref -> t

Linear combination of the inputs.

val affine : ?regularization:float -> rate:float -> Matrix.t Stdlib.ref -> Vector.t Stdlib.ref -> t

Each output is an affine combination of all the inputs.

val activation : [< `ReLU | `Sigmoid ] -> int -> t

Apply an activation function on each input.

val squared_distance : Vector.t -> t

Half of the square of the euclidean distance to a given target.

val softmax : int -> t

Apply the softmax function (to turn logits into probabilities).

val softmax_ce : int -> int -> t

Softmax followed by cross-entropy.

val tensor : t Extlib.List.t -> t

Tensor product of lines.