pub trait SaveToNpz {
    fn save<P: AsRef<Path>>(&self, path: P) -> ZipResult<()> { ... }
    fn write<W>(
        &self,
        _filename_prefix: &str,
        _w: &mut ZipWriter<W>
    ) -> ZipResult<()>
    where
        W: Write + Seek
, { ... } }
Expand description

Something that can be saved to a .npz (which is a .zip).

All super::Modules in nn implement SaveToNpz, and the zips are formatted in a .npz fashion.

Provided Methods

Save this object into the .npz file determined located at path.

Example:

let model: (Linear<5, 10>, Linear<10, 5>) = Default::default();
model.save("tst.npz")?;

Write this object into ZipWriter w with a base filename of filename_prefix.

Example:

let model: Linear<5, 10> = Default::default();
let mut zip = ZipWriter::new(...);
model.write("0.", &mut zip)?;
model.write("1.", &mut zip)?;

Will save a zip file with the following files in it:

  • 0.weight.npy
  • 0.bias.npy
  • 1.weight.npy
  • 1.bias.npy

Implementations on Foreign Types

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

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

  1. self.0.write("0.", w)
  2. self.1.write("1.", w)

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

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

  1. self.0.write("0.", w)
  2. self.1.write("1.", w)

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

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

  1. self.0.write("0.", w)
  2. self.1.write("1.", w)

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

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

  1. self.0.write("0.", w)
  2. self.1.write("1.", w)

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

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

  1. self.0.write("0.", w)
  2. self.1.write("1.", w)

Implementors