Export TMVA MLP to ONNX

Hello!

I have trained a TMVA Multilayer Perceptron (MLP) but would now like to export the trained classifier for preservation. There are extensive possibilities to import classifiers from Keras, ONNX, … to TMVA using SOFIE. But it doesn’t seem to support exporting. It only seems to be possible to save trained classifiers as XML (to be read with TMVA) or C classes. It would however be much interoperable if there was an option to export directly to the logic of other machine-learning tools, ideally ONNX.

Is anyone aware of how to do this directly from TMVA or, if need be, using an external tool?

Thanks for your help!
Martin

Hi Martin,

Thanks for the post and welcome to the ROOT Community!

I do not think this is natively supported, but @moneta could have a proposal.

Cheers,
Danilo

Hi!

Given this currently seems to be a gap in functionality, I’ve cooked up a small script that reads in a TMVA .xml with Keras and then exports it to .onnx.

Just it in case that’s of use to anyone else: it lives in the petrify-bdt git repository and can be executed as
python3 tmvamlp.py <weights file>.xml

Cheers,
Martin