Tutorial

ONNX Runtime provides an easy way to run machine learned models with high performance on CPU or GPU without dependencies on the training framework. Machine learning frameworks are usually optimized for batch training rather than for prediction, which is a more common scenario in applications, sites, and services. At a high level, you can:

  1. Train a model using your favorite framework.
  2. Convert or export the model into ONNX format. See ONNX Tutorials for more details.
  3. Load and run the model using ONNX Runtime.

In this tutorial, we will briefly create a pipeline with scikit-learn, convert it into ONNX format and run the first predictions.

Step 1: Train a model using your favorite framework

We’ll use the famous iris datasets.

Step 2: Convert or export the model into ONNX format

ONNX is a format to describe the machine learned model. It defines a set of commonly used operators to compose models. There are tools to convert other model formats into ONNX. Here we will use ONNXMLTools.

Step 3: Load and run the model using ONNX Runtime

We will use ONNX Runtime to compute the predictions for this machine learning model.

The code can be changed to get one specific output by specifying its name into a list.