Skip to main content

Posts

Showing posts from April, 2020

Mini-project: Training a DNN in Python and exporting it to the ONNX format to run its predictions in a C++ micro-service

Python is nowadays the favourite platform for many machine learning scientists. It is an easy to learn language that provides a vast number of nice data science and AI tools perfect for rapid prototyping.

Models trained using Python DNN libraries like PyTorch and Tensorflow usually perform well enough to be used for production runs, but there are some situations that require the predictions to be run in C++ i.e., when best performance is required or when the model needs to be integrated with an existing C++ codebase.

ONNX (Open Neural Network Exchange) is an AI framework designed to allow interoperability between ML/DL frameworks. It allows, for example, models trained in scikit-learn, PyTorch, TensorFlow and other popular frameworks to be converted to the "standard" ONNX format for later use in any programming language with an existing ONNX runtime.

In this mini-project we trained a "dummy" DNN network (single task target predictor) in Python with PyTorch, exporte…