Struct burn_import::pytorch::LoadArgs
source · pub struct LoadArgs {
pub file: PathBuf,
pub key_remap: Vec<(Regex, String)>,
}
Expand description
Arguments for loading a PyTorch file.
§Fields
file
- The path to the file to load.key_remap
- A vector of tuples containing a regular expression and a replacement string. See regex::Regex::replace for more information.
§Notes
Use Netron to inspect the keys of the PyTorch file (.pt extension).
§Examples
use burn_import::pytorch::{LoadArgs, PyTorchFileRecorder};
use burn::record::FullPrecisionSettings;
use burn::record::Recorder;
let args = LoadArgs::new("tests/key_remap/key_remap.pt".into())
.with_key_remap("conv\\.(.*)", "$1"); // // Remove "conv" prefix, e.g. "conv.conv1" -> "conv1"
let record = PyTorchFileRecorder::<FullPrecisionSettings>::default()
.load(args)
.expect("Should decode state successfully");
Fields§
§file: PathBuf
The path to the file to load.
key_remap: Vec<(Regex, String)>
A list of key remappings.
Implementations§
source§impl LoadArgs
impl LoadArgs
sourcepub fn with_key_remap(self, pattern: &str, replacement: &str) -> Self
pub fn with_key_remap(self, pattern: &str, replacement: &str) -> Self
Set key remapping.
§Arguments
pattern
- The Regex pattern to be replaced.replacement
- The pattern to replace with.
See Regex for the pattern syntax and Replacement for the replacement syntax.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for LoadArgs
impl Send for LoadArgs
impl Sync for LoadArgs
impl Unpin for LoadArgs
impl UnwindSafe for LoadArgs
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more