Skip to content
A Python package for the ONNX->Chainer model conversion
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This tool provides a way to convert ONNX models to Chainer models.


The Python packages can be install via pip3 install chainer onnx numpy.

How to install

  1. pip3 install -e .
  2. python3 -c "import onnx2chainer"
  3. python3 test

How to Use

import onnx
import onnx2chainer

model_onnx = onnx.load("path/to/onnx/model")
model_chainer = onnx2chainer.onnxToChainer(model_onnx)

x = a_xp_array
y = model_chainer(x)

See for more details.

How to Test

The test script

  1. downloads ONNX models as well as test datasets from The ONNX Model Zoo (might be O(GiB)),
  2. generate a Chainer model from each of them, and
  3. verify the generated models by comparing output of the models and grand-truth outputs, as follows.
Testing bvlc_alexnet.tar.gz            with test_data_set_0: |y_chainer - y_true| / |y_true| = 5.27e-07
Testing bvlc_reference_caffenet.tar.gz with test_data_set_0: |y_chainer - y_true| / |y_true| = 5.24e-08
Testing bvlc_googlenet.tar.gz          with test_data_set_0: |y_chainer - y_true| / |y_true| = 9.00e-07
Testing resnet50.tar.gz                with test_data_set_0: |y_chainer - y_true| / |y_true| = 3.70e-08
Testing mnist.tar.gz                   with test_data_set_0: |y_chainer - y_true| / |y_true| = 5.78e-04
Testing vgg19.tar.gz                   with test_data_set_0: |y_chainer - y_true| / |y_true| = 9.68e-07

Note that the error of MNIST is relatively larger than others because the model does not have softmax.

Supported ONNX Operations

You can’t perform that action at this time.