TMVA Tutorial Fatal error

Hi Root Forum,

While trying out the TMVA tutorial : CNN classification for Python, I keep getting the same fatal error. I opted for using keras.
My python version is Python 3.6.16
root-config --python-version: 3.6.9

I had to adjust the code of the tutorial slightly for it to run, the “theOption” arguments in the factory.bookmethod TMVA.Factory() and loader.PrepareTrainingAndTestTree() had to be adjusted slightly. The problem is that a fatal error occurs for the bookmethod, and some warning occur at the start of the program but I am not sure if that is related. The error is not really insightful so if there is anybody who can help me that would me much appreciated.

Here Is my code:
tutorial.py (13.9 KB)

Warnings:

WARNING:tensorflow:From /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/keras/initializers.py:94: calling TruncatedNormal.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
WARNING:tensorflow:From /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
WARNING:tensorflow:From /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/ops/nn_impl.py:183: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
2022-11-24 02:00:38.306121: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA

Fatal ERROR:

<FATAL>                         : 
***> abort program execution
Traceback (most recent call last):
  File "tutorial.py", line 390, in <module>
    'H:V:VarTransform=D,G:FilenameModel=model_cnn.h5:FilenameTrainedModel=trained_model_cnn.h5:NumEpochs=10:BatchSize=100')
TypeError: none of the 3 overloaded methods succeeded. Full details:
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader* loader, TString theMethodName, TString methodTitle, TString theOption = "") =>
    TypeError: could not convert argument 2
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader* loader, TMVA::Types::EMVA theMethod, TString methodTitle, TString theOption = "") =>
    runtime_error: FATAL error
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader*, TMVA::Types::EMVA, TString, TString, TMVA::Types::EMVA, TString) =>
    TypeError: takes at least 6 arguments (4 given)

ROOT Version: 6.26/10 Ubuntu 18.04 pre-compiled
Platform: Ubuntu
Compiler: GCC 7.5


Hi @steven1,

I am sure that @moneta can help you with this. My guess is that the tutorial might need to be revised (as I think the call should match the second overload, cited below), no @moneta?

Cheers,
J.

Hi @jalopezg,
Thank you for the reply!
Do you think it currently does not match correctly with the second overload? My perception is that it does match correctly, but does not execute properly hence the fatal error. The same happens when I execute a Pytorch example.

Let’s ping @moneta on that!

Hi,
The tutorial TMVA_CNN_Classification.py should run correctly if you are using the ROOT master version, where we have the correct Pythonization for TMVA.
Now if you are using 6.26 after some changes we can make the tutorial working, but you have made few errors in updating the tutorial. You need to provide the correct string for the options since you cannot use command line arguments in 6.26.
You have to read carefully the error message when using Python, because it can be misleading.

Here is the updated tutorial that should work. I have also removed the transformations like decor relation which will not work with a dataset with so many input features.
If you have some further issues please let me know

Best,

Lorenzo

tutorial.py (13.9 KB)

Hi @moneta,

Thank you for the details on the updated tutorial. However I still get the same fatal error for both pytorch and keras. Does that indicate that my root installation is not correct, since it was working for you? It is the pre-compiled version as mentioned.

Info in <TMVA_CNN_Classification>: Booking convolutional keras model
<FATAL>                         : Unknown method index in map: 26
***> abort program execution
Traceback (most recent call last):
  File "tutorial_new.py", line 390, in <module>
    factory.BookMethod(loader, TMVA.Types.kPyKeras, 'PyKeras',
TypeError: none of the 3 overloaded methods succeeded. Full details:
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader* loader, TString theMethodName, TString methodTitle, TString theOption = "") =>
    TypeError: could not convert argument 2
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader* loader, TMVA::Types::EMVA theMethod, TString methodTitle, TString theOption = "") =>
    runtime_error: FATAL error
  TMVA::MethodBase* TMVA::Factory::BookMethod(TMVA::DataLoader*, TMVA::Types::EMVA, TString, TString, TMVA::Types::EMVA, TString) =>
    TypeError: takes at least 6 arguments (4 given)

Hi,

It looks you are having this error:

are you having this line in your code ?

TMVA.PyMethodBase.PyInitialize()

Lorenzo

Hi Lorenzo,

I do have that line. Actually

print(TMVA.PyMethodBase.PyIsInitialized())

returns 1.

Other than the warnings and the error I send earlier it does not output any clues on what is going wrong.
I feel like the amount of output I get from the terminal is minimal or suppressed, even though I have verbose mode on?