Module numeric::io
[−]
[src]
Saving and loading data to and from disk.
HDF5
The recommended way to save/load data in Numeric is using HDF5.
Note: The HDF5 library will by default not be thread-safe (it depends on how you compiled it), so do not call either of these functions concurrently.
Saving to HDF5 file:
use std::path::Path; use numeric::Tensor; let path = Path::new("output.h5"); let t: Tensor<i32> = Tensor::range(100); let ret = t.save_hdf5(&path);
The data will be saved to the group /data
.
Loading from HDF5 file
Now, we can load this file:
use std::path::Path; use numeric::Tensor; let path = Path::new("output.h5"); let t = match numeric::io::load_hdf5_as_f64(&path, "/data") { Ok(v) => v, Err(e) => panic!("Failed: {}", e), };
Note that since we need to know the type of t
at compile time, it doesn't matter that we
saved the file as i32
, we have to specify how to load it. The way this is done is that it
will load the i32
natively and then convert it to f64
. If your data converted, you simply
have to load it as the same type as you know is in the file.
Functions
load_hdf5_as_f32 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_f64 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_i8 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_i16 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_i32 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_i64 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_isize |
Load HDF5 file and convert to specified type. |
load_hdf5_as_u8 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_u16 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_u32 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_u64 |
Load HDF5 file and convert to specified type. |
load_hdf5_as_usize |
Load HDF5 file and convert to specified type. |