-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[tmva][sofie] New Keras Parser from SOFIE #20871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[tmva][sofie] New Keras Parser from SOFIE #20871
Conversation
|
Thanks for the PR! One two things to do before a more detailed review is to merge #15790 and fix the test failures in this PR. But I also have a general question, the same as in #19692 (comment): why not remove the old C++ parser at the same time, so we don't risk code duplication and user confusion? |
Test Results 22 files 22 suites 3d 16h 42m 49s ⏱️ For more details on these failures, see this check. Results for commit ed4c2bd. ♻️ This comment has been updated with latest results. |
0c9d958 to
d592d31
Compare
e7a5b7c to
fc8f6a4
Compare
|
@lmoneta, it seems the new Python files are missing in the relevant diff --git a/bindings/pyroot/pythonizations/python/CMakeLists.txt b/bindings/pyroot/pythonizations/python/CMakeLists.txt
index 4c96c7556c7..e9bbed07628 100644
--- a/bindings/pyroot/pythonizations/python/CMakeLists.txt
+++ b/bindings/pyroot/pythonizations/python/CMakeLists.txt
@@ -58,7 +58,33 @@ if(tmva)
ROOT/_pythonization/_tmva/_rtensor.py
ROOT/_pythonization/_tmva/_tree_inference.py
ROOT/_pythonization/_tmva/_utils.py
- ROOT/_pythonization/_tmva/_gnn.py)
+ ROOT/_pythonization/_tmva/_gnn.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/__init__.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/generate_keras_functional.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/generate_keras_sequential.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser_test_function.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/__init__.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/batchnorm.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/binary.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/concat.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/conv.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/dense.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/elu.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/flatten.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/identity.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/layernorm.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/leaky_relu.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/permute.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/pooling.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/reshape.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/relu.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/rnn.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/selu.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/sigmoid.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/softmax.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/swish.py
+ ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/tanh.py)
if(dataframe)
list(APPEND PYROOT_EXTRA_PYTHON_SOURCES
ROOT/_pythonization/_tmva/_batchgenerator.py) |
fe22713 to
fef1ba1
Compare
…ers and added tests for them. Imported Keras within the required functions. Created new CMakeLists.txt file for the keras parser. Made changes in the pythonization CMake file to build the keras parser files
…aced import keras_version with get_keras_version and called it in necessary files
… directory. Used import numpy statements within the parser functions to avoid slowing down the import of ROOT.
… Keras3 Sequential In Keras3 Sequential output of a layer can have a different name than input of the next layer. Since in sequnrial model each layer has a single input/output use as output names the layer name (which is unique) and set as input name for the next layer
…d C++ parser - use new python keras parser for parsing a model into SOFIE. Since new parser is only Python base, move some tutorials from C++ to Python Remove also tutorial dependency on TMVA_Higgs_Classification by creating and training a model in tutorial TMVA_SOFIE_Keras_HiggsModel.py Adapt also RSofieReader for using new Python Keras parser
…ndency to test Fix also an issue in a SOFIE tutorial
With this fix now the Keras parser can parse the convolutional model generated by TMVA_CNN_Classification
Fix bug in Squeeze operator when the axes to squeeze are provided. In that case a wrong usage of vector.erase was done. Fix the Keras parser tests when convolutions with channel_first are not supported (e.g. on CPU impelmentations of tensorflows)
The bug fixes the closing of the loops on the outer axis. The tests worked because the number of outer axes and normalization axes was the same in the test scripts.
…axpy Avoid using saxpy and use directly the wrapper function in Sofie_common to call blas and automatically also include the bias addition
69d4ae7 to
dd9635a
Compare
The Python files were moved in root-project@3281aa9 in a different location and it was not done during the rebase. This is now fixed Fix also an issue in parsing input shape from the Keras model and add support also for the different types of input shapes Increase also test tolerance from 10-3 to 10-2
dd9635a to
ed4c2bd
Compare
|
Hi @lmoneta, about these ruff check bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tmva/_sofie/_parser/_keras --fixRuff can just be installed with pip: I think it would be worth it to add a commit that does does these automatic fixes! Then we don't have to update the code again later just for that. |
This PR superseeds #19692 fixing the conflicts and add some bug fixes