# Incompatibility among tensorflow of lxplus with tensorflow macbook pro, colab notebook and SWAN

**URL:** <https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336>\
**Category:** TMVA\
**Tags:** python\
**Created:** [September 11, 2023, 6:59pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336 "2023-09-11T18:59:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 11, 2023, 6:59pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/1 "2023-09-11T18:59:59Z")

</div>

Hello everybody,  
I would like to request help from experts for the following problem:  
I use neural networks in VBF signal analysis, a Multilayer perceptron, which saves the model as follows:  
##############################################

from tensorflow.keras import utils  
from tensorflow.python.keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint

#callbacks–\> criteria to earlyStopping and best configuration  
es = EarlyStopping(monitor=‘loss’, min\_delta=1e-10, patience=10, verbose=1)  
rlr = ReduceLROnPlateau(monitor= ‘loss’, factor= 0.2, patience = 5, verbose=1)  
mcp = ModelCheckpoint(filepath=‘BN\_tf230\_64\_all\_2j\_3j.h5’, monitor=‘loss’, save\_best\_only=True, verbose=1)

# Number of training epochs

nepochs=6

# Batch size

batch=64

# Trainclassifier

history = model.fit(X\_train\_val,  
Y\_train\_val,  
epochs=nepochs,  
sample\_weight=W\_train\_val,  
batch\_size=batch,  
verbose=1, # switch to 1 for more verbosity  
validation\_split=0.3,callbacks=[mcp])  
##############################################  
Then I get the best result from the network and use it to add variables to my tree, the result that goes to combine. I was unable to build a satisfactory network model in lxplus, so I made a model on my computer and imported it into my lxplus. Over the last year there were no problems. I used tensorflow 2.2 and python3.8, but when I needed to use BatchNormalization to improve the p-value and significance. BatchNormalization was not compatible with tensorflow 2.2 and I upgraded the version, but it became incompatible with use in lxplus with answers like:  
#############################################  
[fassunca@lxplus749 private]$ cat errors.2383655.0.err  
Traceback (most recent call last):  
File “To\_combine\_add\_NNVBF\_2j\_3j\_2018\_642.py”, line 59, in   
model = load\_model(‘BN\_tf230\_64\_all\_2j\_3j.h5’, compile = False)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py”, line 234 , in load\_model  
model = model\_from\_config(model\_config, custom\_objects=custom\_objects)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py”, line 324 , in model\_from\_config  
return deserialize(config, custom\_objects=custom\_objects)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py”, line 74 , in deserialize  
printable\_module\_name=‘layer’)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic\_utils.py”, line 192 , in deserialize\_keras\_object  
list(custom\_objects.items())))  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/engine/sequential.py”, line 349 , in from\_config  
custom\_objects=custom\_objects)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py”, line 74 , in deserialize  
printable\_module\_name=‘layer’)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic\_utils.py”, line 194 , in deserialize\_keras\_object  
return cls.from\_config(cls\_config)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/engine/base\_layer.py”, line 402 , in from\_config  
return cls(\*\*config)  
File “/cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/lib/python3.6/site-packages/tensorflow/python/keras/engine/input\_layer.py”, line 69 , in **init**  
raise ValueError(‘Unrecognized keyword arguments:’, kwargs.keys())  
ValueError: (‘Unrecognized keyword arguments:’, dict\_keys([‘ragged’]))  
#############################################  
I tried using Jupyter Notebook and SWAN and the problem repeated itself  
I use condor with following source:  
############################################  
#!/bin/bash  
source /cvmfs/sft.cern.ch/lcg/views/LCG\_96py3cu10/x86\_64-centos7-gcc7-opt/setup.sh  
cd /afs/cern.ch/work/f/fassunca/private/

python To\_combine\_add\_NNVBF\_2j\_3j\_2018\_642.py

########################################

I couldn’t run a neural network on lxplus and I need some tips to solve this problem, so has anyone come across something similar or could give me a tip? Thanks in advance  
cheers  
Fernando Assuncao

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [September 18, 2023, 7:57am UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/2 "2023-09-18T07:57:58Z")

</div>

Dear @fernandoaugusto12

Thank you for the report. Let me invite @moneta in the discussion , maybe he has already seen something like this in the past.

Cheers,  
Vincenzo

---

<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:** [September 18, 2023, 9:25am UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/3 "2023-09-18T09:25:34Z")

</div>

Hi,  
It looks to me you are using a very old setup in lxplus (LC\_96). This is few years old and contains version 1 of Tensorflow, which is not compatible with your model. I would strongly recommend to use a newer tensorflow version of lxplus, for example I see that LCG\_98 has version 2.1 of tensorflow,  
try for example to source ` /cvmfs/sft.cern.ch/lcg/views/LCG_98py3cu10/x86_64-centos7-gcc8-opt/setup.sh`

Lorenzo

---

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 18, 2023, 12:55pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/4 "2023-09-18T12:55:53Z")

</div>

> [@moneta](#):
>
> source ` /cvmfs/sft.cern.ch/lcg/views/LCG_98py3cu10/x86_64-centos7-gcc8-opt/setup.sh`

Hello Lorenzo, thank you very much!  
Could you tell me the latest version of tensorflow and what the source is?  
Thank you very much in advance!

---

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 18, 2023, 12:59pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/5 "2023-09-18T12:59:10Z")

</div>

vpadulan thank you very much for the answer, I managed to create an entire virtual environment with miniconda, but the problems persist, however I believe that the answer provided by lorenzo is the answer, although I think it is necessary to have the most up-to-date version of tensorflow possible.

---

<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:** [September 18, 2023, 2:01pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/6 "2023-09-18T14:01:41Z")

</div>

Hi,

I think in SWAN the latest version you can have is 2.8. Using LCG\_98 (as above) you have tensorflow 2.1.

Lorenzo

---

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 18, 2023, 2:03pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/7 "2023-09-18T14:03:41Z")

</div>

> [@moneta](#):
>
> Hi,
> 
> I think in SWAN the latest version you can have is 2.8. Using LCG\_98 (as above) you have tensorflow 2.1.

And to use 2.8, what is the source?  
thank you again

---

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 19, 2023, 1:48pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/8 "2023-09-19T13:48:59Z")

</div>

My friends, thank you very much! My problem was solved 🙂

---

<div class="post-metadata">

**Author:** ![fernandoaugusto12](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fernandoaugusto12/32/25210_2.png) [@fernandoaugusto12](https://root-forum.cern.ch/u/fernandoaugusto12)\
**Post date:** [September 19, 2023, 1:51pm UTC](https://root-forum.cern.ch/t/incompatibility-among-tensorflow-of-lxplus-with-tensorflow-macbook-pro-colab-notebook-and-swan/56336/9 "2023-09-19T13:51:21Z")

</div>

Thanks for answering my question! My problem has been resolved
