# Training TMultiLayerPerceptron in multi-core mode

**URL:** <https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929>\
**Category:** TMVA\
**Tags:** tmva, root\
**Created:** [December 29, 2022, 5:16pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929 "2022-12-29T17:16:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![garciaduarte1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/garciaduarte1/32/35005_2.png) [@garciaduarte1](https://root-forum.cern.ch/u/garciaduarte1)\
**Post date:** [December 29, 2022, 5:16pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/1 "2022-12-29T17:16:58Z")

</div>

I am training a TMultiLayerPerceptron neural network that has 11 neurons in the input and output layers (with continuous values in the interval [0,1]), with three hidden layers, each with 50 neurons. It takes more than 12 hours to go though 5000 cycles using one core.  
Is there a way I can parallelize the training to use more than one core?

_ROOT Version:_ 6.26/06  
_Platform:_ macOS Big Sur  
_Compiler:_ Clang 13.0.0

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 5, 2023, 9:46am UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/2 "2023-01-05T09:46:20Z")

</div>

I guess @moneta may help you.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [January 5, 2023, 4:31pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/3 "2023-01-05T16:31:41Z")

</div>

Hi,  
I don’t think this old class supports training in multi-core. For neural network we have new classes in TMVA for deep learning which can be trained using stochastic optimisers like ADAM and working both on GPU and multi-core.  
See the tutorial [`TMVA_HIggs_Classification.C`](https://root.cern/doc/v626/TMVA __Higgs__ Classification_8C.html).

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![garciaduarte1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/garciaduarte1/32/35005_2.png) [@garciaduarte1](https://root-forum.cern.ch/u/garciaduarte1)\
**Post date:** [January 5, 2023, 6:41pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/4 "2023-01-05T18:41:06Z")

</div>

Thank you Lorenzo! This week I began working with TMVA starting with the tutorial TMVA\_Classification.C using DNN\_CPU and DNN\_GPU, however, the code says:  
`: Start of deep neural network training on CPU using MT, nthreads = 1`  
I installed the Intel TBB library as indicated in page 115 of the manual and recompiled ROOT. However, I get the same result. Is there something related with the example, or should I get more than one thread being used with this example?  
Cheers,  
Jeremias

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [January 5, 2023, 6:57pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/5 "2023-01-05T18:57:53Z")

</div>

Hello Jeremiads,  
To enable MT , if you have a ROOT build supporting it, you need to do:

```auto
ROOT::EnableImplicitMT(0)

```

for using all the available threads of the machine, otherwise you specify the number of threads instead of `0`.

Lorenzo

---

<div class="post-metadata">

**Author:** ![garciaduarte1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/garciaduarte1/32/35005_2.png) [@garciaduarte1](https://root-forum.cern.ch/u/garciaduarte1)\
**Post date:** [January 5, 2023, 8:48pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/6 "2023-01-05T20:48:35Z")

</div>

> [@moneta](#):
>
> `ROOT::EnableImplicitMT(0)`

Amazing! It works!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [January 19, 2023, 8:49pm UTC](https://root-forum.cern.ch/t/training-tmultilayerperceptron-in-multi-core-mode/52929/7 "2023-01-19T20:49:19Z")

</div>

Closed on January 19, 2023, 8:49pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
