# Root and Deep Neural Network

**URL:** <https://root-forum.cern.ch/t/root-and-deep-neural-network/28295>\
**Category:** TMVA\
**Created:** [March 13, 2018, 10:15am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295 "2018-03-13T10:15:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 13, 2018, 10:15am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/1 "2018-03-13T10:15:12Z")

</div>

Dear experts,

- I want to use Deep Neural Network method. I saw the TensorFlow package but I wonder if such method much already exit in root?
- my concern is that my input are root file and I wonder how to adapt it to TensorFlow? Does someone already have this experience?  
Regards

---

<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:** [March 13, 2018, 10:26am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/2 "2018-03-13T10:26:18Z")

</div>

@moneta will be able to tell you more about it I think.

Note also, searching the forum, I found this:

> [@Framework to use ROOT NTuples in Tensorflow](https://root-forum.cern.ch/t/framework-to-use-root-ntuples-in-tensorflow/23572):
>
> Dear all, sorry, if this is not the proper place, but I thought it could be useful for some in the HEP community. Our bachelor student Max Welsch has written a so-called NNFlow framework which allows to read-in ROOT NTuples by converting them to a Numpy array and then use them in Google Tensorflow. The NNFlow framework is still early work but so far working fine and a simple example is provided in the existing documentation. Here is the link to the framework: [github.com/kit-cn-cms/NNFlow](https://github.com/kit-cn-cms/NNFlow) B…

---

<div class="post-metadata">

**Author:** ![behrenhoff](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/behrenhoff/32/12285_2.png) [@behrenhoff](https://root-forum.cern.ch/u/behrenhoff)\
**Post date:** [March 13, 2018, 10:32am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/3 "2018-03-13T10:32:21Z")

</div>

You can always use the “manual” approach: read ROOT tree -\> convert relevant columns to csv -\> read with TF (or use Keras or similar frameworks).

---

<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:** [March 13, 2018, 2:12pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/4 "2018-03-13T14:12:23Z")

</div>

Hi,

You can also use Keras (and its Tensorflow implementation) directly from TMVA.  
You provide as input an input description model which can be written by Keras.  
See [http://nbviewer.jupyter.org/github/iml-wg/tmvatutorials/blob/master/TMVA\_PyMVA.ipynb](http://nbviewer.jupyter.org/github/iml-wg/tmvatutorials/blob/master/TMVA_PyMVA.ipynb)  
for a simple Keras example

Best Regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 13, 2018, 2:29pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/5 "2018-03-13T14:29:31Z")

</div>

Dear Moneta,  
is there and example on how to use DNNClassification of TensorFlow? from your link it’s not clear to me how I can do that?  
Regards

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 13, 2018, 2:31pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/6 "2018-03-13T14:31:49Z")

</div>

Dear behrenhoff,  
is there a code with already allow make root file into cvs files?  
Regards

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 14, 2018, 10:51am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/7 "2018-03-14T10:51:52Z")

</div>

Dear experts,  
any ideas?  
Regards

---

<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:** [March 14, 2018, 12:12pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/8 "2018-03-14T12:12:45Z")

</div>

> [@calbet](#):
>
> make root file into cvs files?

> [@ROOT tree to CSV file format](https://root-forum.cern.ch/t/root-tree-to-csv-file-format/27633):
>
> Hello everyone, I want to convert a root file into .csv file format. Could someone provide the best way to go about this?. Many Thanks,

---

<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:** [March 14, 2018, 3:19pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/9 "2018-03-14T15:19:24Z")

</div>

Hi,

You can find code example in the TMVA tutorial directory  
[https://root.cern.ch/doc/master/group\_\_tutorial\_\_tmva.html](https://root.cern.ch/doc/master/group __tutorial__ tmva.html)

For example, TMVA\_Classification.C provides examples of using all TMVA methods (including the DNN)

[https://root.cern.ch/doc/master/TMVAClassification\_8C.html](https://root.cern.ch/doc/master/TMVAClassification_8C.html)

and then in the eras directory (unfortunatly not linked from the previous web page) you see examples on using the Keras interface.  
See then these in GitHub:

> **[root-project/root](https://github.com/root-project/root/tree/master/tutorials/tmva/keras)**
>
> root - The official ROOT repository

Lorenzo

---

<div class="post-metadata">

**Author:** ![wellatiger](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wellatiger/32/15619_2.png) [@wellatiger](https://root-forum.cern.ch/u/wellatiger)\
**Post date:** [March 14, 2018, 4:41pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/10 "2018-03-14T16:41:07Z")

</div>

Hello,

converting to .csv depends on the structure of your TTree. Basically you read in the branches (loop) and write them to ‘txt’ file one event per row.

Cheers,

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 14, 2018, 4:49pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/11 "2018-03-14T16:49:23Z")

</div>

Dear Moneta,  
TMVA DNN is quite new right? if I look here (1) the current release is "TMVA version 4.2.0 " made in 2013, and I wonder if it include DNN? It is the right place to get the last TMVA? Maybe should I work with a special root\_TMVA?  
Regards

(1)  
[http://tmva.sourceforge.net/](http://tmva.sourceforge.net/)

---

<div class="post-metadata">

**Author:** ![behrenhoff](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/behrenhoff/32/12285_2.png) [@behrenhoff](https://root-forum.cern.ch/u/behrenhoff)\
**Post date:** [March 14, 2018, 5:03pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/12 "2018-03-14T17:03:52Z")

</div>

TMVA is included in ROOT, the sourceforge page is outdated. Find the TMVA user guide here: [https://root.cern.ch/guides/tmva-manual](https://root.cern.ch/guides/tmva-manual)

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 14, 2018, 5:09pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/13 "2018-03-14T17:09:59Z")

</div>

Dear Behrenhoff,

- thank you.
- I ran (1) with root -l ./TMVAClassification.C. In that code I set only “Use[“DNN\_GPU”] = 1”. So all the other method are set to 0. When I run I got the error message (2). I have root "6.10/04 ". Should I install more things on my side?  
Regards

(1)  
[https://root.cern.ch/doc/master/TMVAClassification\_8C\_source.html](https://root.cern.ch/doc/master/TMVAClassification_8C_source.html)

(2)  
: Transformation, Variable selection :  
: Input : variable ‘myvar1’ \<—\> Output : variable ‘myvar1’  
: Input : variable ‘myvar2’ \<—\> Output : variable ‘myvar2’  
: Input : variable ‘var3’ \<—\> Output : variable ‘var3’  
: Input : variable ‘var4’ \<—\> Output : variable ‘var4’  
 : CUDA backend not enabled. Please make sure you have CUDA installed and it was successfully detected by CMAKE.  
 : CUDA backend not enabled. Please make sure you have CUDA installed and it was successfully detected by CMAKE.  
\*\*\*\> abort program execution  
terminate called after throwing an instance of ‘std::runtime\_error’  
what(): FATAL error

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 14, 2018, 5:16pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/14 "2018-03-14T17:16:20Z")

</div>

When I use “Use[“DNN\_CPU”] = 1” I have the error message (1)?  
Regards

(1)  
: Transformation, Variable selection :  
: Input : variable ‘myvar1’ \<—\> Output : variable ‘myvar1’  
: Input : variable ‘myvar2’ \<—\> Output : variable ‘myvar2’  
: Input : variable ‘var3’ \<—\> Output : variable ‘var3’  
: Input : variable ‘var4’ \<—\> Output : variable ‘var4’  
 : Multi-core CPU backend not enabled. Please make sure you have a BLAS implementation and it was successfully detected by CMake as well that the imt CMake flag is set.  
 : Multi-core CPU backend not enabled. Please make sure you have a BLAS implementation and it was successfully detected by CMake as well that the imt CMake flag is set.  
\*\*\*\> abort program execution  
terminate called after throwing an instance of ‘std::runtime\_error’  
what(): FATAL error

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 14, 2018, 5:20pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/15 "2018-03-14T17:20:07Z")

</div>

I can see from the manual that the"standard backend" can be use on any platform but when I use Architecture=STANDARD, as option, it says that it is not available (1)!  
Regards

(1)  
: Transformation, Variable selection :  
: Input : variable ‘myvar1’ \<—\> Output : variable ‘myvar1’  
: Input : variable ‘myvar2’ \<—\> Output : variable ‘myvar2’  
: Input : variable ‘var3’ \<—\> Output : variable ‘var3’  
: Input : variable ‘var4’ \<—\> Output : variable ‘var4’  
 : The STANDARD architecture has been deprecated. Please use Architecture=CPU or Architecture=CPU.See the TMVA Users’ Guide for instructions if you encounter problems.  
 : The STANDARD architecture has been deprecated. Please use Architecture=CPU or Architecture=CPU.See the TMVA Users’ Guide for instructions if you encounter problems.  
\*\*\*\> abort program execution  
terminate called after throwing an instance of ‘std::runtime\_error’  
what(): FATAL error

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 15, 2018, 8:57am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/16 "2018-03-15T08:57:14Z")

</div>

Dear experts,  
is there a way to access the “standard backend”? right now I can’t use the other DNN options.  
Regards

---

<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:** [March 16, 2018, 10:30am UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/17 "2018-03-16T10:30:46Z")

</div>

Hi,

I am sorry, this is not possible. 😕

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 21, 2018, 5:05pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/18 "2018-03-21T17:05:40Z")

</div>

Dear experts,  
when I used “DNN\_GPU”, it trains and take many times (1), what puzzle me is that i do not see the progress bar despite my request (2). Is it implemented for DNN? if yes is there something wrong?  
Regards

(1)  
TFHandler\_DNN\_GPU : Variable Mean RMS [Min Max]  
: -----------------------------------------------------------  
: Mll01: -0.85850 0.11802 [-1.0000 1.0000]  
: DRll01: -0.29341 0.35139 [-1.0000 1.0000]  
: Ptll01: -0.80687 0.12644 [-1.0000 1.0000]  
: SumPtJet: -0.77872 0.15662 [-1.0000 1.0000]  
: -----------------------------------------------------------  
: Start of neural network training on GPU.  
:  
: Training phase 1 of 1:  
: Epoch | Train Err. Test Err. GFLOP/s Conv. Steps  
: --------------------------------------------------------------

HERE I KEEP WAITING BUT I DO NOT KNOW IF SOMETHING IS WRONG AS I DO NOT SEE THE PROGRESS BAR?!

(2)  
TMVA::Factory \*factory = new TMVA::Factory( “TMVAClassification”, outputFile,  
“!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification” );

---

<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:** [March 22, 2018, 12:48pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/19 "2018-03-22T12:48:32Z")

</div>

Hi,

Thanks for reporting this. On my machine it takes quite some time for the network to be constructed and data loaded. It then output erroneous results. I will make a bug report.

Two questions: What OS/Cuda versions are you running? If you are not running cuda-7.5, do you have the possibility to test with this cuda version? (I have so far only been able to test with cuda 8.0 and 9.0).

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [March 22, 2018, 12:54pm UTC](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295/20 "2018-03-22T12:54:05Z")

</div>

Dear Kailbert,  
it works fine with me, even if yes it takes a long time… But my question is why I do not see the “progress bar”?  
Regards

[Next page](https://root-forum.cern.ch/t/root-and-deep-neural-network/28295.md?page=2)
