A First Look at ONNX

Open Neural Network Exchange Format (ONNX) version 1.0 was released on Wednesday, December 6, 2017. From what I can tell, ONNX is a specification standard for neural network models, so that different deep learning libraries can work together.

According to the Web site at http://www.onnx.ai ONNX was created by Microsoft and Facebook. The ONNX specification appears to have official support from Amazon (AWS), as well as hardware companies AMD, ARM, IBM, Intel, Huawei, NVIDIA, and Qualcomm.

Neural network tools initially supported by ONNX v1 include CNTK, PyTorch, Apache MXNet, Caffe2, and TensorRT. Noticeably missing is official support from Google and their TensorFlow library. However, it appears that there is some sort of converter that allows indirect interoperability with TensorFlow.

The field of AI/ML/NNs is evolving very rapidly, so I’ll have to keep an eye on ONNX.

Now if I was reading this blog post, at this point I’d have only a vague idea of what ONNX is. For me, I never understand a technology until I can see the code in action. So, I whipped up a simple neural network using the CNTK library, version 2.3 and saved the model using the statement:

nnet.save(".\\iris_fnn_v2.model",
  format=C.ModelFormat.CNTKv2)

Then I wrote another little program that loaded the saved model and then used it. The load statement was:

model = C.ops.functions.Function.load(".\\iris_fnn_v2.model",
  format=C.ModelFormat.ONNX)

OK, everything seemed to work.

Then I changed the save and load statements to use the new ONNX format:

nnet.save(".\\iris_fnn_onnx.model",
  format=C.ModelFormat.ONNX)

model = C.ops.functions.Function.load(".\\iris_fnn_onnx.model",
  format=C.ModelFormat.ONNX)

And everything seemed to work again.

Nice. If you examine the two screenshots, you’ll see I got slightly different formats for output values, so there seems to be some minor differences in the models.

Anyway, if ONNX gains traction, it will likely allow different deep learning libraries to interoperate. This could have a huge impact on machine learning and AI.

This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.