pub trait LoadFromNpz {
    fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpzError> { ... }
    fn read<R>(
        &mut self,
        _filename_prefix: &str,
        _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

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")?;

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

Implementations on Foreign Types

Calls LoadFromNpz::read(self.<idx>, ...) on each part of the tuple. See LoadFromNpz.

E.g. for a two tuple (A, B) with base == "", this will call:

  1. self.0.read("0.", r)
  2. self.1.read("1.", r)

Calls LoadFromNpz::read(self.<idx>, ...) on each part of the tuple. See LoadFromNpz.

E.g. for a two tuple (A, B) with base == "", this will call:

  1. self.0.read("0.", r)
  2. self.1.read("1.", r)

Calls LoadFromNpz::read(self.<idx>, ...) on each part of the tuple. See LoadFromNpz.

E.g. for a two tuple (A, B) with base == "", this will call:

  1. self.0.read("0.", r)
  2. self.1.read("1.", r)

Calls LoadFromNpz::read(self.<idx>, ...) on each part of the tuple. See LoadFromNpz.

E.g. for a two tuple (A, B) with base == "", this will call:

  1. self.0.read("0.", r)
  2. self.1.read("1.", r)

Calls LoadFromNpz::read(self.<idx>, ...) on each part of the tuple. See LoadFromNpz.

E.g. for a two tuple (A, B) with base == "", this will call:

  1. self.0.read("0.", r)
  2. self.1.read("1.", r)

Implementors