ONNXImporter<T>
Models & Types · AiDotNet.ModelLoading
Imports weights from ONNX model files.
For Beginners
ONNX (Open Neural Network Exchange) is a standard format for representing machine learning models.
Many pretrained models are distributed in ONNX format. This class extracts the learned weights from ONNX files so you can use them in your models.
Example usage:
var importer = new ONNXImporter<float>();
// Load weights from ONNX file
var weights = importer.LoadWeights("model.onnx");
// Apply to your model
var layer = new DenseLayer<float>(outputSize: 128);
importer.ApplyWeights(layer, weights);
Constructors
| Constructor | Summary |
|---|---|
ONNXImporter(bool verbose) |
Initializes a new instance of the ONNXImporter class. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, Tensor<T>> LoadWeights(string onnxPath) |
Loads all initializer tensors from an ONNX file. |
List<ONNXTensorInfo> GetTensorInfo(string onnxPath) |
Gets information about tensors in an ONNX file without loading them. |
WeightLoadResult ApplyWeights(IWeightLoadable<T> model, Dictionary<string, Tensor<T>> weights, Func<string, string> mapping, bool strict) |
Applies loaded weights to a model using IWeightLoadable. |