Struct tch::nn::VarStore [−][src]
Expand description
A VarStore is used to store variables used by one or multiple layers. It specifies a single device where all variables are stored.
Fields
variables_: Arc<Mutex<Variables>>
Implementations
Returns true if no tensors are currently stored on this var-store.
Returns all the trainable variables for this var-store.
Returns all variables along with their names.
Gets the root path for this variable store.
Variables are named and organized using paths. This function returns the top level path for the var store and can be combined with ‘/’ to create sub-paths.
Saves the var-store variable values to a file.
Weight values for all the tensors currently stored in the var-store gets saved in the given file.
Loads the var-store variable values from a file.
Weight values for all the tensors currently stored in the var-store gets loaded from the given file. Note that the set of variables stored in the var-store is not changed, only the values for these tensors are modified.
Loads the var-store variable values from a file if it exists.
Weight values for the tensors currently stored in the var-store and the given file get loaded from the given file. If a variable in the var store is not present in the given file, it is skipped and its values are not updated. This method should be used if pre-trained weight for only parts of the model are available. Note that the set of variables stored in the var-store is not changed, only the values for these tensors are modified.
Returns a String Vector containing the names of missing variables.
Freezes a var store.
Gradients for the variables in this store are not tracked anymore.
Unfreezes a var store.
Gradients for the variables in this store are tracked again.
Casts all variables in a var store to the target kind .
For floating-point conversion, methods half
, bfloat16
, float
and double
should be preferred as they ensure only float-like variables will be converted
to the target type.
Casts all float-like variable of a var store to half-precision (Half kind).
Casts all float-like variable of a var store to bfloat16-precision (BFloat16 kind).
Casts all float-like variable of a var store to single-precision (Float kind).
Casts all float-like variable of a var store to single-precision (Double kind).
Migrates a var store and all its tensor to a target device.