Torch.Var_storeSourceA 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.
create ?frozen ?device ~name () creates a new variable store on the specified device (defaulting to cpu).
sub t subname returns a var-store corresponding to path subname in t.
Same as sub.
num_trainable_vars t returns the number trainable variables stored in t.
iter_trainable_vars t ~f applies f to all trainable variables stored in t.
all_vars t returns all the variables stored in t.
name t returns the var-store name.
val new_var :
?trainable:Base.bool ->
t ->
shape:Base.int Base.list ->
init:Init.t ->
name:Base.string ->
Tensor.tnew_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.
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.
freeze t freezes all variables in the var-store, none of the variables are trainable anymore and their gradients are not tracked.