# \[TMVA - MLP\] How to export weight class in python?

**URL:** <https://root-forum.cern.ch/t/tmva-mlp-how-to-export-weight-class-in-python/21120>\
**Category:** TMVA\
**Created:** [May 11, 2016, 10:05am UTC](https://root-forum.cern.ch/t/tmva-mlp-how-to-export-weight-class-in-python/21120 "2016-05-11T10:05:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadrino](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nadrino/32/34692_2.png) [@nadrino](https://root-forum.cern.ch/u/nadrino)\
**Post date:** [May 11, 2016, 10:05am UTC](https://root-forum.cern.ch/t/tmva-mlp-how-to-export-weight-class-in-python/21120/1 "2016-05-11T10:05:08Z")

</div>

Hi,

I would like to ask if anyone know a method to export the neural network weight class in python instead of C++ ? By default, TMVA exports all the computed weight in .xml and with a C++ class in a folder called “weight/”. Here is a little piece of code that generate the “weight/” folder with files :

```auto
method = factory.BookMethod(ROOT.TMVA.Types.kMLP, "MLP", "H:!V:NeuronType=tanh:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5" )
factory.TrainAllMethods()
factory.TestAllMethods()
factory.EvaluateAllMethods()
```

Do anyone know how to generate a .py class in the weight/ folder ?

Thanks in advance,  
Adrien

---

<div class="post-metadata">

**Author:** ![sergei](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@sergei](https://root-forum.cern.ch/u/sergei)\
**Post date:** [May 11, 2016, 12:56pm UTC](https://root-forum.cern.ch/t/tmva-mlp-how-to-export-weight-class-in-python/21120/2 "2016-05-11T12:56:07Z")

</div>

Hi Adrien,

We currently don’t support that feature, but can add it if that would be useful.

Cheers,

Sergei

---

<div class="post-metadata">

**Author:** ![nadrino](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nadrino/32/34692_2.png) [@nadrino](https://root-forum.cern.ch/u/nadrino)\
**Post date:** [May 12, 2016, 8:15am UTC](https://root-forum.cern.ch/t/tmva-mlp-how-to-export-weight-class-in-python/21120/3 "2016-05-12T08:15:03Z")

</div>

Thanks for your answer,

I think the feature could be useful, because using pyroot can save a lot of time for coding. I don’t know if it’s possible but if the output files could be controlled explicitly by the user, that would be cool !

Cheers,  
Adrien
