Home | News | Documentation | Download

TMVA TensorFlow Keras interface with python3

Hello,

I am trying to load a TensorFlow Keras model file (in h5 format) using the BookMethod and type as “PyKerasNN”. But this seems to be crashing [1]. This has worked with plain Keras but doesn’t work with TensorFlow Keras. My versions are ROOT 6.22/00, TensorFlow 2.1.0 and python 3.7.6.

I think it is coming from the TMVA::MethodPyKeras class where TMVA calls the ‘Keras.models.load_model’ [2]. This seems to conflict with python3 as keras is now integrated into TensorFlow. On lxplus, only tensor flow keras is supported starting from python3.

Could you please look into this and do the possible fix? Please let me know if you need any other information from my side.

Best,
Angira

[1] - Part of the error message is pasted here -
: Using TensorFlow backend - setting special configuration options
: Using Tensorflow version 2
: Failed to run python code: model = keras.models.load_model(‘model.h5’)

[2] - https://github.com/root-project/root/blob/master/tmva/pymva/src/MethodPyKeras.cxx#L267

Hi,

Which Keras version are you using ? You should update to a version larger than 2.3.0 the first one compatible with Tensorflow 2, see https://github.com/keras-team/keras/releases/tag/2.3.0

Curently MethodPyKeras is not compatible directly with Keras API of Tensorflow ( tf.keras), but we are planning to support this. How are you getting Tensorflow in lxplus, from cvmfs ?

Best

Lorenzo

Hi Lorenzo,

Thank you for your response, sorry for my late reply.
Indeed I get Tensorflow 2.3.1 from cvmfs [1] on lxplus. The Keras API version implemented in tensorflow is 2.2.4.
These are centrally installed on lxplus and I don’t have direct privileges to update them :smiley:

Regards,
Angira

[1] - /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/setup.sh

Hi,
I have opened a github issue on this to update ROOT for tf.keras
See https://github.com/root-project/root/issues/6553

Lorenzo