Skip to content

Commit 7fa8c6d

Browse files
committed
[tmva][sofie] Only one statement per line in PyRunString
This follows up on 29b8e84, fixing a syntax error: ```txt Python error message: File "<string>", line 1 import tensorflow.keras as keras ^ SyntaxError: multiple statements found while compiling a single statement ```
1 parent bec6eb3 commit 7fa8c6d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tmva/sofie_parsers/src/RModelParser_Keras.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,10 @@ RModel Parse(std::string filename, int batch_size){
873873
// For each layer: type,name,activation,dtype,input tensor's name,
874874
// output tensor's name, kernel's name, bias's name
875875
// None object is returned for if property doesn't belong to layer
876+
PyRunString("import tensorflow",fGlobalNS,fLocalNS);
877+
PyRunString("import tensorflow.keras as keras",fGlobalNS,fLocalNS);
876878
PyRunString("import tensorflow\n", fGlobalNS, fLocalNS);
877-
PyRunString("import tensorflow.keras as keras\n"
878-
"version = keras.__version__\n"
879-
"major = int(version.split('.')[0])\n"
880-
"if major >= 3:\n"
879+
PyRunString("if int(keras.__version__.split('.')[0]) >= 3:\n"
881880
" raise RuntimeError(\n"
882881
" 'TMVA SOFIE Keras parser supports Keras 2 only.\\n'\n"
883882
" 'Keras 3 detected. Please export the model to ONNX.\\n'\n"

0 commit comments

Comments
 (0)