Skip to main content

models.OnnxModel

A network trained elsewhere (PyTorch, Keras), loaded from an ONNX file

Usage

Source

models.OnnxModel()

and run in float64.

Supports the operators a tabular network exports: Gemm, Linear, MatMul, broadcasting arithmetic, the common activations, Softmax, Concat, Gather embeddings, reshapes and reductions. Anything else is refused at load, with the operators the file uses.

Parameters

path: str

Raises

ValueError
If the file cannot be read or parsed, or uses an unsupported operator.

Attributes

Name Description
inputs The graph’s inputs as dicts with name, rank, shape (sizes
ops The operators the graph uses.
outputs The graph’s output names.

inputs

The graph’s inputs as dicts with name, rank, shape (sizes

inputs: list[dict]

the file fixes, None where it leaves one free) and integer (category codes for an embedding).


ops

The operators the graph uses.

ops: list[str]


outputs

The graph’s output names.

outputs: list[str]

Methods

Name Description
from_bytes() Loads a model from the bytes of an ONNX file.
run() Runs the graph.

from_bytes()

Loads a model from the bytes of an ONNX file.

Usage

Source

from_bytes(data)
Parameters
data: bytes
Returns
OnnxModel

run()

Runs the graph.

Usage

Source

run(inputs)
Parameters
inputs: list of (list of int, list of float)
One (shape, values) per graph input, in input order, values row-major.
Returns
list of (list of int, list of float)
One (shape, values) per output.