# Info about two different training

**URL:** <https://root-forum.cern.ch/t/info-about-two-different-training/31594>\
**Category:** TMVA\
**Created:** [November 14, 2018, 6:46pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594 "2018-11-14T18:46:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![moricciani](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@moricciani](https://root-forum.cern.ch/u/moricciani)\
**Post date:** [November 14, 2018, 6:46pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/1 "2018-11-14T18:46:21Z")

</div>

Hi, I try TMVAClassification with two Prepare…:

1. sprintf(Stringa,“nTrain\_Signal=%d:nTrain\_Background=%d:nTest\_Signal=0:nTest\_Background=0:SplitMode=Random:NormMode=NumEvents:!V”, nTrainSVar, nTrainBVar);  
dataloader-\>PrepareTrainingAndTestTree( mycuts, mycutb, Stringa);
2. dataloader-\>PrepareTrainingAndTestTree( mycutb, nTrainSVar, nTrainBVar, 0, 0, “SplitMode=Random:NormMode=NumEvents:!V”);  
And I got different results, is it normal ?

---

<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:** [November 14, 2018, 7:07pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/2 "2018-11-14T19:07:33Z")

</div>

Hi,

That looks like it should be expected. You are using two different cut setups. In 1) you place a cut on both signal and background while in 2) you only cut on background.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![moricciani](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@moricciani](https://root-forum.cern.ch/u/moricciani)\
**Post date:** [November 14, 2018, 8:21pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/3 "2018-11-14T20:21:07Z")

</div>

I don’t use cut at all

---

<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:** [November 14, 2018, 9:15pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/4 "2018-11-14T21:15:10Z")

</div>

Hi,

So do I understand correctly then that your variables `mycuts` and `mycutb` are both equal to `""` (or equivalently `TCut("")`)?

Other than that difference the two calls are equivalent. In fact, in 2) and internal option string in constructed that is exactly the one in 1). In this case, no, different behaviour is _not_ expected.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![moricciani](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@moricciani](https://root-forum.cern.ch/u/moricciani)\
**Post date:** [November 14, 2018, 10:48pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/5 "2018-11-14T22:48:21Z")

</div>

Exact but I find differences : this is the problem …[tmva3.pdf](https://root-forum.cern.ch/uploads/default/original/3X/c/8/c8a357bd837789954af288e01a2bac466f537f22.pdf) (839.6 KB)

---

<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:** [November 14, 2018, 11:52pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/6 "2018-11-14T23:52:07Z")

</div>

Hi,

If I understand your presentation correctly you find differences in the output of 3 classifiers (consistent over both runs), namely DNN\_CPU, DNN\_GPU and TMlpANN.

It might be the case (can’t remember the details from the top of my head) that these methods have inherent randomness (I think e.g. the DNN uses “hogwild” parallelisation i.e. the gradients is updated non-deterministically). Could you verify that you get identical output when you run either option 1) or 2) two times in a row?

Cheers,  
Kim

---

<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:** [November 15, 2018, 9:08am UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/7 "2018-11-15T09:08:07Z")

</div>

Hi,

When using the DNN you will not get the same results, because of different weight initialisation and different batch ordering when training.  
If you want reproducible result, this is possible In the coming release 6.16 when using the new MethodDL,  
_TMVA::Types::kDL_ , by typing TCpu\<Double\_t\>::SetRandomSeed(seed)

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![Yoann](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/5fc32e/32.png) [@Yoann](https://root-forum.cern.ch/u/Yoann)\
**Post date:** [February 22, 2019, 4:36pm UTC](https://root-forum.cern.ch/t/info-about-two-different-training/31594/8 "2019-02-22T16:36:41Z")

</div>

I would like to share my experience with randomness in TMVA training output (using _TMlpANN_ algorithm), Lorenzo pointed out.  
What I found interesting was to run a handful of training and then compute for each event the distribution of the classifiers normalized by the cut value of each training.  
In that case, normalized classifiers above(below) 1 are cut(not cut) or vice versa depending which side is cut…  
One realizes that a given event can be cut for some trainings and not cut for others due to this random initialization of the weights.  
By doing so, I think one is able to study the _robustness_ of the TMVA algorithm, which is particularly interesting for noisy data.

Yoann
