ONNX (.onnx)

Background & Context

    • Open format for neural network models (NetChain[], NetGraph[], etc.)
    • Stores models and various metadata
    • ONNX is an acronym for Open Neural Network Exchange
    • Binary file format based on Protobuf

Import & Export

  • Import["file.onnx"] imports the net stored in the specified file, returning it as a NetGraph[] or similar construct.
  • Import["file.onnx",elem] imports the specified element elem.

Import Elements

  • Import elements include:
  • "ArrayAssociation"parameter arrays as an association
    "ArrayList"parameter arrays as a list
    "Description"human-readable description for the model
    "ONNXGraph"ONNX representation of the net
    "ModelDomain"model namespace or domain
    "ModelVersion"integer version number of the model
    "Net"Wolfram Language representation of the net, including all initialized arrays (default)
    "IRVersion"version of the ONNX intermediate representation used by the model
    "OperatorSetVersion"operator sets the model is compatible with
    "ProducerName"name of the tool used to generate the model
    "ProducerVersion"version of the generating tool
    "RawData"full, unprocessed contents of the file, including the graph representation and all metadata
    "UninitializedNet"Wolfram Language representation of the net, without any arrays

Examples

open allclose all

Basic Examples  (1)

Import a net in ONNX format:

Show the Import elements available in this file:

Import Elements  (13)

ArrayAssociation  (1)

Obtain an association mapping names to arrays for a given ONNX net:

ArrayList  (1)

Obtain a list of arrays for a given ONNX net:

Description  (1)

Obtain the description for a given ONNX net:

ONNXGraph  (1)

Obtain the ONNX representation of a given net:

ModelDomain  (1)

Obtain the ONNX model domain of a given net:

ModelVersion  (1)

Obtain the ONNX model version of a given net:

Net  (1)

Import the ONNX model as a Wolfram Language net:

This is the default element:

IRVersion  (1)

Obtain the version of the ONNX intermediate representation of a given net:

OperatorSetVersion  (1)

Obtain the ONNX operator sets used by a given net:

ProducerName  (1)

Obtain the name of the tool used to produce a given net:

ProducerVersion  (1)

Obtain the version of the tool used to produce a given net:

RawData  (1)

Obtain the full unprocessed contents of a given ONNX file:

UninitializedNet  (1)

Import the ONNX model as an uninitialized Wolfram Language net:

Introduced in 2020
 (12.1)