Function dfdx::numpy::save

source · []
pub fn save<T, P>(path: P, t: &T) -> Result<()>where
    T: NumpyDtype + NumpyShape + WriteNumbers,
    P: AsRef<Path>,
Expand description

Saves the data to a .npy file. This calls write().

This is implemented for an arbitrarily shaped array. See WriteNumbers for how this is done (recursive array traits!).

Currently only implemented for f32 and f64 arrays. To add another base type, you can implement NumpyShape

Example Usage:

use dfdx::numpy;
let arr = [[1.0f32, 2.0, 3.0], [4.0, 5.0, 6.0]];
numpy::save("test.npy", &arr);

Returns the number of bytes written to the file.