The ONNX-mlpack converter can take any ONNX graph and convert it to an mlpack neural network. This is done by matching individual mlpack layers to subgraphs of the ONNX network using a rule matching engine, and then selecting the overall best match of the network.
- Dependencies: make sure that you have, available on your system,
- mlpack and its dependencies ensmallen, cereal, and Armadillo](https://arma.sourceforge.net); if not installed, these will be autodownloaded during the CMake comnfiguration
- ONNX (on Debian,
libonnx-devis sufficient) - Protobuf (on Debian,
libprotobuf-devis sufficient)
- Configuration: create a build directory and use CMake to configure:
mkdir build/
cd build/
cmake ../- Build the converter:
make onnx_mlpack_converter- Run the converter:
src/onnx_mlpack_converter <input_network.onnx> <output_mlpack_network.bin>Once the converter has been run, you can load the network into mlpack as a
DAGNetwork:
#define MLPACK_ENABLE_ANN_SERIALIZATION
#include <mlpack.hpp>
using namespace mlpack;
int main()
{
DAGNetwork<> network;
Load("output_mlpack_network.bin", network);
// now you can use network.Predict(), network.Train(), etc.
}This repository is under active development! At this particular moment, support is pretty primitive, but it is actively being expanded. If you have a network that does not match properly, or encounter other problems, please feel free to open a bug report and we will look into the issue.