export_weights

Function export_weights 

Source
pub fn export_weights<P, B, M>(
    path: P,
    module: &M,
    model_name: &str,
    input_shape: &[i64],
) -> Result<()>
where P: AsRef<Path>, B: Backend, M: Module<B>,
Expand description

Export a module’s weights as an ONNX model file.

This creates a “weight-only” ONNX model: the initializer tensors contain the model’s learned parameters, and the graph describes a simple sequential pass from input to output.

§Arguments

  • path: output file path (typically .onnx)
  • module: the trained module to export
  • model_name: name for the ONNX graph
  • input_shape: shape of the model’s input tensor

§Example

let model = Linear::new(784, 10, true, DType::F32, &dev)?;
export_weights("model.onnx", &model, "classifier", &[1, 784])?;