Skip to content

Conversation

@PrasannaKasar
Copy link

@PrasannaKasar PrasannaKasar commented Jan 18, 2026

This Pull request:

This pull request implements fixes during testing the New SOFIE Keras Parser.
The tests included Functional and Sequential models which comprised of Conv2D, GlobalAveragePool2D and AveragePool2D for which Keras doesn't yet support channels_first parameter while training it on CPU, on platforms such as mac beta 26, mac 14 and 15. Note that this error is generated during the training phase of the models and not while testing the models. There seems to be no fix for this but to use channels_last parameter during training. Since only some of the platforms face these issues, there's no need to disable the tests completely. I'll create an issue on Keras repository as well mentioning this and will add it in this PR as a reference.

Changes or fixes:

During the training of these types of models we'll use a try-except block and check if there's any error generated during training, it would print a statement saying "Error while traning the keras model". While generating the inference code we'll then see if the model file exists, if not skip the test. Though this works, it makes the tests fail silently.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

PrasannaKasar and others added 15 commits August 20, 2025 13:13
…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.
Do not use anymore .h5 files but .keras since .h5 is not anymore supported in keras3
the algorithm option is not anymore supported from scikit versions 1.6
Remove it in the MethodAdaBoost

The SOFIE tutorials which require pymva need also a valid Keras parser, so exclude them if Keras is an unsupported version
… 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
…ils to train, it's test will be skipped. If model's file path is not found, the test will be skipped. Enabled Conv2d and GlobalAveragePooling2d tests
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 14 times, most recently from 9a9c216 to 4c24c9a Compare February 6, 2026 10:57
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 3 times, most recently from 9aa6e2a to cc7d91d Compare February 7, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants