Skip to main content

save_model

Function save_model 

Source
pub fn save_model(
    model: &Model,
    path: impl AsRef<Path>,
    config: &SaveConfig,
) -> Result<()>
Expand description

Save a model to a file

§Arguments

  • model - The model to save
  • path - Output file path
  • config - Save configuration (format, options)

§Example

use entrenar::io::{Model, ModelMetadata, save_model, SaveConfig, ModelFormat};

let params = vec![
    ("weight".to_string(), Tensor::from_vec(vec![1.0, 2.0], true)),
];
let model = Model::new(ModelMetadata::new("my-model", "linear"), params);
let config = SaveConfig::new(ModelFormat::Json);

save_model(&model, "model.json", &config).expect("failed to save model");