Skip to main content

load_state_dict

Function load_state_dict 

Source
pub fn load_state_dict<M: Module + ?Sized>(
    module: &M,
    state: &HashMap<String, Tensor>,
) -> Result<(), SerializeError>
Expand description

Copy state into the module’s parameters in place.

Strict: every parameter must be present with the right shape, and no extra tensors are allowed. Values are copied onto each parameter’s own device, so optimizers holding the parameters keep working.