pub fn export_weights<P, B, M>(
path: P,
module: &M,
model_name: &str,
input_shape: &[i64],
) -> Result<()>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 exportmodel_name: name for the ONNX graphinput_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])?;