Trait dfdx::nn::LoadFromNpz
source · pub trait LoadFromNpz<E: Dtype + NumpyDtype, D: Device<E>>: TensorCollection<E, D> {
// Provided methods
fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpzError> { ... }
fn read<R>(&mut self, r: &mut ZipArchive<R>) -> Result<(), NpzError>
where R: Read + Seek { ... }
}
Expand description
Something that can be loaded from a .npz
file (which is a zip
file).
All super::Modules in nn implement LoadFromNpz, and the zips are formatted in a .npz
fashion.
Provided Methods§
sourcefn load<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpzError>
fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpzError>
Loads data from a .npz
zip archive at the specified path
.
Example:
ⓘ
let mut model: (Linear<5, 10>, Linear<10, 5>) = Default::default();
model.load("tst.npz")?;
sourcefn read<R>(&mut self, r: &mut ZipArchive<R>) -> Result<(), NpzError>where
R: Read + Seek,
fn read<R>(&mut self, r: &mut ZipArchive<R>) -> Result<(), NpzError>where R: Read + Seek,
Reads this object from a ZipArchive. r
with a base filename of filename_prefix
.
Example:
ⓘ
let mut model: Linear<5, 10> = Default::default();
let mut zip = ZipArchive::new(...);
model.read("0", &mut zip)?;
Will try to read data from the following files:
0.weight.npy
0.bias.npy