# Use TMVA to make a ROOT macro?

**URL:** <https://root-forum.cern.ch/t/use-tmva-to-make-a-root-macro/36026>\
**Category:** TMVA\
**Created:** [September 13, 2019, 8:21pm UTC](https://root-forum.cern.ch/t/use-tmva-to-make-a-root-macro/36026 "2019-09-13T20:21:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skip](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/skip/32/16865_2.png) [@Skip](https://root-forum.cern.ch/u/Skip)\
**Post date:** [September 13, 2019, 8:21pm UTC](https://root-forum.cern.ch/t/use-tmva-to-make-a-root-macro/36026/1 "2019-09-13T20:21:57Z")

</div>

I’m fairly new to the whole ML world and somewhat of a novice coder, so I hope this question isn’t too basic for here. I’ve made a simple, multilayer perceptron in Python for a metric that I’d like to be able to call in ROOT. I have the model and all the weights; is there a way to migrate the prediction model into ROOT? I’m not looking to do any of the training in ROOT; just use the end result. It’s built with Keras using TensorFlow backend.

Barring that, is there a way to just pull the weights and hand-code the matrix multiplication? It’s only a few layers (ReLU and sigmoid), so it ought to be pretty straightforward, but I can’t quite figure it out (also, I want to learn how to do this in TMVA if possible for when the model gets more robust). Thanks!

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [September 16, 2019, 8:57am UTC](https://root-forum.cern.ch/t/use-tmva-to-make-a-root-macro/36026/2 "2019-09-16T08:57:02Z")

</div>

Hi,

I think these two tutorials could be helpful for you:

1. [Creating a model for use with TMVA](https://root.cern/doc/master/GenerateModel_8py.html)
2. [Using a model with TMVA](https://root.cern/doc/master/ClassificationKeras_8py.html)

Both can be found [here](https://root.cern/doc/master/group __tutorial__ tmva__keras.html).

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![Skip](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/skip/32/16865_2.png) [@Skip](https://root-forum.cern.ch/u/Skip)\
**Post date:** [September 16, 2019, 4:30pm UTC](https://root-forum.cern.ch/t/use-tmva-to-make-a-root-macro/36026/3 "2019-09-16T16:30:12Z")

</div>

I’ll check those out; thank you!
