# Pytorch and TMVA: Failed to get predictions

**URL:** <https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463>\
**Category:** TMVA\
**Created:** [October 29, 2021, 9:09am UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463 "2021-10-29T09:09:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@fjh](https://root-forum.cern.ch/u/fjh)\
**Post date:** [October 29, 2021, 9:09am UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/1 "2021-10-29T09:09:31Z")

</div>

when l run the following URL on [Tutorial: TMVA PyTorch Interface | GSoC](https://anirudhdagar.ml/gsoc/tmva/pytorch/root/2020/08/21/TMVA-PyTorch-Tutorial.html#introduction) , the following error occurs when l run the line of code All, please do you know what causes this? thank you very much!

* * *

runtime\_error Traceback (most recent call last)  
 in   
----\> 1 factory.TrainAllMethods()

runtime\_error: void TMVA:🏭:TrainAllMethods() =\>  
runtime\_error: FATAL error

Factory : Dataset[dataset] : Variable transform ‘FLAnalysisType=Classification’ unknown.Train all methods  
Factory : Train method: Fisher for Classification  
:  
: Preparing the Decorrelation transformation…  
: Preparing the Gaussian transformation…  
TFHandler\_Fisher : Variable Mean RMS [Min Max]  
: -----------------------------------------------------------  
: var1: 0.0089276 1.0040 [-3.1195 5.7307]  
: var2: 0.0079596 0.99992 [-3.1195 5.7307]  
: var3: 0.0079663 1.0001 [-3.1195 5.7307]  
: var4: 0.0074148 0.99773 [-3.1195 5.7307]  
: -----------------------------------------------------------  
Fisher : Results for Fisher coefficients:  
: NOTE: The coefficients must be applied to TRANFORMED variables  
: List of the transformation:  
: – Deco  
: – Gauss  
: -----------------------  
: Variable: Coefficient:  
: -----------------------  
: var1: -0.220  
: var2: -0.054  
: var3: +0.034  
: var4: +0.473  
: (offset): -0.001  
: -----------------------  
: Elapsed time for training with 8000 events: 0.0264 sec  
Fisher : [dataset] : Evaluation of Fisher on training sample (8000 events)  
: Elapsed time for evaluation of 8000 events: 0.0135 sec  
: Creating xml weight file: dataset/weights/TMVAClassification\_Fisher.weights.xml  
: Creating standalone class: dataset/weights/TMVAClassification\_Fisher.class.C  
Factory : Training finished  
:  
Factory : Train method: PyTorch for Classification  
:  
:  
: ================================================================  
: H e l p f o r M V A m e t h o d [PyTorch] :  
:  
: PyTorch is a scientific computing package supporting  
: automatic differentiation. This method wraps the training  
: and predictions steps of the PyTorch Python package for  
: TMVA, so that dataloading, preprocessing and evaluation  
: can be done within the TMVA system. To use this PyTorch  
: interface, you need to generatea model with PyTorch first.  
: Then, this model can be loaded and trained in TMVA.  
:  
:  
: \<Suppress this message by specifying “!H” in the booking option\>  
: ================================================================  
:  
: Preparing the Decorrelation transformation…  
: Preparing the Gaussian transformation…  
TFHandler\_PyTorch : Variable Mean RMS [Min Max]  
: -----------------------------------------------------------  
: var1: 0.0089276 1.0040 [-3.1195 5.7307]  
: var2: 0.0079596 0.99992 [-3.1195 5.7307]  
: var3: 0.0079663 1.0001 [-3.1195 5.7307]  
: var4: 0.0074148 0.99773 [-3.1195 5.7307]  
: -----------------------------------------------------------  
TFHandler\_PyTorch : Variable Mean RMS [Min Max]  
: -----------------------------------------------------------  
: var1: 0.0089276 1.0040 [-3.1195 5.7307]  
: var2: 0.0079596 0.99992 [-3.1195 5.7307]  
: var3: 0.0079663 1.0001 [-3.1195 5.7307]  
: var4: 0.0074148 0.99773 [-3.1195 5.7307]  
: -----------------------------------------------------------  
: Split TMVA training data in 6400 training events and 1600 validation events  
: Print Training Model Architecture  
: Option SaveBestOnly: Only model weights with smallest validation loss will be stored  
: Elapsed time for training with 8000 events: 2.26 sec  
PyTorch : [dataset] : Evaluation of PyTorch on training sample (8000 events)  
 : Failed to get predictions  
\*\*\*\> abort program execution

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 29, 2021, 9:17am UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/2 "2021-10-29T09:17:46Z")

</div>

Maybe @moneta can help on this

---

<div class="post-metadata">

**Author:** ![Ilan\_Kaboom](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ilan_kaboom/32/31236_2.png) [@Ilan\_Kaboom](https://root-forum.cern.ch/u/Ilan_Kaboom)\
**Post date:** [October 19, 2022, 12:14pm UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/3 "2022-10-19T12:14:48Z")

</div>

Hey, did you work this out by any chance? I am having the exact same problem

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 19, 2022, 12:38pm UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/4 "2022-10-19T12:38:51Z")

</div>

Welcome to the ROOT Forum! Let’s ask @moneta again

---

<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:** [October 19, 2022, 9:07pm UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/5 "2022-10-19T21:07:09Z")

</div>

Hi,  
Can you please pst your code giving this problem ?  
Are you using C++ or Python ? You can look also at these 2 tutorials for using PyTorch with TMVA (these work for ROOT master)

- C++ [ROOT: tutorials/tmva/TMVA\_CNN\_Classification.C File Reference](https://root.cern.ch/doc/master/TMVA __CNN__ Classification_8C.html)  
-Python version: [ROOT: tutorials/tmva/TMVA\_CNN\_Classification.py File Reference](https://root.cern.ch/doc/master/TMVA __CNN__ Classification_8py.html)

Lorenzo

---

<div class="post-metadata">

**Author:** ![Lisa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lisa/32/31257_2.png) [@Lisa](https://root-forum.cern.ch/u/Lisa)\
**Post date:** [October 20, 2022, 12:08pm UTC](https://root-forum.cern.ch/t/pytorch-and-tmva-failed-to-get-predictions/47463/6 "2022-10-20T12:08:22Z")

</div>

Hi, did you work it out by any chance?
