Serializable

Trait Serializable 

Source
pub trait Serializable {
    // Required methods
    fn state_dict(&self) -> StateDict;
    fn load_state_dict(&mut self, state_dict: &StateDict) -> Result<()>;

    // Provided methods
    fn save<P: AsRef<Path>>(&self, path: P) -> Result<()> { ... }
    fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<()> { ... }
}
Expand description

Trait for models that can be serialized

Required Methods§

Source

fn state_dict(&self) -> StateDict

Get state dictionary

Source

fn load_state_dict(&mut self, state_dict: &StateDict) -> Result<()>

Load state dictionary

Provided Methods§

Source

fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>

Save model to file

Source

fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Load model from file

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§