package torch

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Torch.Var_storeSource

Sourcemodule Tensor_id : sig ... end
Sourcetype 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.

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

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

Sourceval sub : t -> Base.string -> t

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

Sourceval subi : t -> Base.int -> t

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

Sourceval (/) : t -> Base.string -> t

Same as sub.

Sourceval (//) : t -> Base.int -> t

Same as subi.

Sourceval num_trainable_vars : t -> Base.int

num_trainable_vars t returns the number trainable variables stored in t.

Sourceval iter_trainable_vars : t -> f:(Tensor_id.t -> Tensor.t -> Base.unit) -> Base.unit

iter_trainable_vars t ~f applies f to all trainable variables stored in t.

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

all_vars t returns all the variables stored in t.

Sourceval name : t -> Base.string

name t returns the var-store name.

Sourceval device : t -> Device.t

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

Sourcemodule Init : sig ... end
Sourceval new_var : ?trainable:Base.bool -> t -> shape:Base.int Base.list -> init:Init.t -> name:Base.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.

Sourceval new_var_copy : ?trainable:Base.bool -> t -> src:Tensor.t -> name:Base.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.

Sourceval freeze : t -> Base.unit

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

Sourceval unfreeze : t -> Base.unit

unfreeze t unfreezes the 'trainable' variables from t.

Sourceval copy : src:t -> dst:t -> Base.unit
OCaml

Innovation. Community. Security.