Skip to content

Commit 35f6c10

Browse files
committed
[tutorials] Don't import TensorFlow in TMVA tutorials if tmva-pymva=OFF
It's not needed in that case, and like this we avoid LLVM symbol clashes.
1 parent 0dceb42 commit 35f6c10

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

tutorials/tmva/TMVA_CNN_Classification.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,24 @@
2222
## The difference between signal and background is in the gaussian width.
2323
## The width for the background gaussian is slightly larger than the signal width by few % values
2424

25+
import ROOT
26+
2527
import os
2628
import importlib.util
2729

30+
useKerasCNN = False
31+
32+
if ROOT.gSystem.GetFromPipe("root-config --has-tmva-pymva") == "yes":
33+
useKerasCNN = True
34+
2835
opt = [1, 1, 1, 1, 1]
2936
useTMVACNN = opt[0] if len(opt) > 0 else False
30-
useKerasCNN = opt[1] if len(opt) > 1 else False
37+
useKerasCNN = opt[1] if len(opt) > 1 else useKerasCNN
3138
useTMVADNN = opt[2] if len(opt) > 2 else False
3239
useTMVABDT = opt[3] if len(opt) > 3 else False
3340
usePyTorchCNN = opt[4] if len(opt) > 4 else False
3441

35-
tf_spec = importlib.util.find_spec("tensorflow")
36-
if tf_spec is None:
37-
useKerasCNN = False
38-
print("TMVA_CNN_Classificaton","Skip using Keras since tensorflow is not installed")
39-
else:
42+
if useKerasCNN:
4043
import tensorflow
4144

4245
# PyTorch has to be imported before ROOT to avoid crashes because of clashing

tutorials/tmva/TMVA_RNN_Classification.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,14 @@ def MakeTimeData(n, ntime, ndim):
153153

154154
nTotEvts = 2000 # total events to be generated for signal or background
155155

156-
useKeras = True
156+
useKeras = False
157157

158158
useTMVA_RNN = True
159159
useTMVA_DNN = True
160160
useTMVA_BDT = False
161161

162-
tf_spec = importlib.util.find_spec("tensorflow")
163-
if tf_spec is None:
164-
useKeras = False
165-
ROOT.Warning("TMVA_RNN_Classificaton","Skip using Keras since tensorflow is not installed")
162+
if ROOT.gSystem.GetFromPipe("root-config --has-tmva-pymva") == "yes":
163+
useKeras = True
166164

167165

168166
rnn_types = ["RNN", "LSTM", "GRU"]

0 commit comments

Comments
 (0)