load_state_dict_with_mapping

Function load_state_dict_with_mapping 

Source
pub fn load_state_dict_with_mapping<P: AsRef<Path>>(
    path: P,
    mapper: &StateDictMapper,
) -> Result<StateDict>
Expand description

Load a state dict from a file and apply transformations

This is a convenience wrapper around load_state_dict that applies a StateDictMapper transformation before returning the result.

ยงExample

use volta::io::{load_state_dict_with_mapping, mapping::StateDictMapper};

let mapper = StateDictMapper::new()
    .strip_prefix("model.")
    .transpose_pattern("weight");

let state = load_state_dict_with_mapping("model.bin", &mapper)?;