package torch

  1. Overview
  2. Docs
type t

A VarStore is used to store all the variables used by a given model. The model creates variables by calling Var_store.new_var for which it has to provide a name. Var_store.sub creates a sub-directory in the var store which is useful to group some variables together.

val create : ?frozen:bool -> ?device:Device.t -> name:string -> unit -> t

create ?frozen ?device ~name () creates a new variable store on the specified device (defaulting to cpu).

val sub : t -> string -> t

sub t subname returns a var-store corresponding to path subname in t.

val subi : t -> int -> t

subi is similar to sub but uses an integer for the subname.

val (/) : t -> string -> t

Same as sub.

val (//) : t -> int -> t

Same as subi.

val trainable_vars : t -> Tensor.t list

trainable_vars t returns all the trainable variables stored in t.

val all_vars : t -> (string * Tensor.t) list

all_vars t returns all the variables stored in t.

val name : t -> string

name t returns the var-store name.

val device : t -> Device.t

device t returns the device used to store variables hold by t.

module Init : sig ... end
val new_var : ?trainable:bool -> t -> shape:int list -> init:Init.t -> name:string -> Tensor.t

new_var ?trainable t ~shape ~init ~name creates a new variable in t with shape shape and the specified initialization. The tensor associated with the variable is returned.

val new_var_copy : ?trainable:bool -> t -> src:Tensor.t -> name:string -> Tensor.t

new_var_copy ?trainable t ~src ~name creates a new variable in t by copying tensor src, so using the same shape, element kind and element values.

val freeze : t -> unit

freeze t freezes all variables in the var-store, none of the variables are trainable anymore and their gradients are not tracked.

val unfreeze : t -> unit

unfreeze t unfreezes the 'trainable' variables from t.

val copy : src:t -> dst:t -> unit
OCaml

Innovation. Community. Security.