package caisar

  1. Overview
  2. Docs
type ('a, 'b) t = ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t
type shape = Base.int Base.array
val pp_shape : Ppx_deriving_runtime.Format.formatter -> shape -> Ppx_deriving_runtime.unit
val all_coords : shape -> Base.int Base.list Base.list

create sh initialize a tensor with the given shape sh with a default value, depending of the type of the tensor

type ('a, 'b) t_kind =
  1. | K_int : (Base.int64, Stdlib.Bigarray.int64_elt) t_kind
  2. | K_float : (Base.float, Stdlib.Bigarray.float64_elt) t_kind
val create : shape -> ('a, 'b) t_kind -> ('a, 'b) t

get t idx returns the value in tensor t stored at coordinates idx. Throw an error if the coordinate is invalid.

val get : ('a, 'b) t -> shape -> 'a

set_idx t idx v sets value v for tensor t at idx. Throw an error if the coordinate is invalid.

val set : ('a, 'b) t -> shape -> 'a -> Base.unit

equal f t1 t2 applies f to all values of t1 and t2, and returns true if all applications of f returned true.

val equal : ('a -> 'a -> Base.bool) -> ('a, 'b) t -> ('a, 'b) t -> Base.bool

get_shape t returns the shape of t.

val get_shape : ('a, 'b) t -> shape

flatten t returns a flattened version of t.

val flatten : ('a, 'b) t -> 'a Base.list

num_neurons sh returns the total number of neurons given a shape

val num_neurons : shape -> Base.int

get flatnd_idx idx sh flt returns the value that would be stored at index idx under a tensor of shape sh, given the flattened version of this tensor flt.

val get_flatnd_idx : idx:shape -> sh:shape -> 'a Base.list -> 'a

transpose_2d t returns a copy of the tensor t with its two last dimension exchanged.

val transpose_2d : ('a, 'b) t -> ('a, 'b) t

unsqueeze sh1 sh2 returns the lowest common shape between sh1 and sh2, and None if there is no common shape. A common shape is when a shape of higher dimension has only 1 coordinates on non-shared dimensions with the other.

val unsqueeze : sh1:shape -> sh2:shape -> shape Base.option
OCaml

Innovation. Community. Security.