Skip to content

Conversation

@lmoneta
Copy link
Member

@lmoneta lmoneta commented Jun 7, 2024

This Pull request starts adding support for new TF version (2.16) coming with Keras3 API.

In addition, it improves the evaluation of models for regression and multi-class by using all events instead of the single event as before. With TF 2.16 s not possible anymore to disable eager execution and have a decent speed i evaluating the model

@lmoneta lmoneta requested a review from bellenot as a code owner June 7, 2024 14:16
@github-actions
Copy link

github-actions bot commented Jun 7, 2024

Test Results

    23 files      23 suites   3d 19h 12m 38s ⏱️
 3 835 tests  3 833 ✅ 0 💤 2 ❌
80 507 runs  80 505 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit 1414858.

♻️ This comment has been updated with latest results.

@dpiparo
Copy link
Member

dpiparo commented Jun 10, 2024

Thanks for the PR. Is this code tested anywhere?

@dpiparo dpiparo self-requested a review June 26, 2024 08:27
Copy link
Member

@dpiparo dpiparo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@guitargeek
Copy link
Contributor

guitargeek commented May 4, 2025

Hi @lmoneta, how should we proceed here? There is now TensorFlow 2.19 already, and the last TensorFlow we support is still the 2.15 release. I think the real question is: it it actually worth it to support inference with TensorFlow/Keras given the declining popularity of TensorFlow?

The list can go on.

@guitargeek
Copy link
Contributor

Also, maybe it makes sense to split the TensorFlow compatibility and the other commit with the general improvements into two separate PRs? Then we can already merge the other improvements, because they are covered by the CI. For the TensorFlow compatibility, we have once again the chicken-and-egg problem that it will only be covered once we allow TF>=2.16 in our requirements.txt for the CI images to pick up, but then builds will be red until the compatibility fix is merged...

guitargeek added a commit to guitargeek/root that referenced this pull request Jun 22, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 23, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 23, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 23, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 23, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] #15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
@guitargeek guitargeek mentioned this pull request Jun 24, 2025
guitargeek added a commit that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] #15790
guitargeek added a commit that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] #15790
guitargeek added a commit that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] #15790
guitargeek added a commit that referenced this pull request Jun 24, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] #15790
@guitargeek
Copy link
Contributor

guitargeek commented Jun 25, 2025

For the TensorFlow compatibility, we have once again the chicken-and-egg problem that it will only be covered once we allow TF>=2.16 in our requirements.txt for the CI images to pick up, but then builds will be red until the compatibility fix is merged...

This problem was resolved now by disabling tmva-pymva in the CI, so that the newest TensorFlow could be installed in the CI images. @lmoneta, if you want, you can now resolve the merge conflicts in this PR to continue working on compatibility with the newest TensorFlow, and our CI will cover it! You just have to turn tmva-pymva back on as well:
https://github.com/root-project/root/blob/master/.github/workflows/root-ci-config/buildconfig/global.txt#L94

GalinBistrev2 pushed a commit to GalinBistrev2/root that referenced this pull request Jun 30, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Aug 2, 2025
This follows up on 3923ba5, where I forgot to change this. If a
feature is not tested in the CI and included in the binaries, we should
also not enable it by default when people build ROOT from source.

Also, clarify the TensorFlow support status in the option description
(see also root-project#15790).
guitargeek added a commit that referenced this pull request Aug 4, 2025
This follows up on 3923ba5, where I forgot to change this. If a
feature is not tested in the CI and included in the binaries, we should
also not enable it by default when people build ROOT from source.

Also, clarify the TensorFlow support status in the option description
(see also #15790).
martinfoell pushed a commit to martinfoell/root that referenced this pull request Oct 9, 2025
Right now we don't support the newest TensorFlow releases after the 2.15
series, initially released in November 2023 [1].

Support for TensorFlow>=2.16 is worked on [2], but it's difficult to
make progress if we don't have TensorFlow>=2.16 in our CI images.
And we veto it from our CI image via the `requirements.txt` mechanism.

To continue, we need to temporarily disable PyMVA in the CI, such that
we can include the newest TensorFlow version in our images, and then
re-enable it in the PR that fixes support for the newest TensorFlow.
This is what is done in this commit.

Supporting the newest TensorFlow became a bit more important now that we
also have another feature besides PyMVA that uses TensorFlow: the
RBatchGenerator. It would not good to hold off testing the
actively-developed RBatchGenerator on newer TensorFlow versions, just
because PyMVA prevents us from installing these on our CI.

[1] https://github.com/tensorflow/tensorflow/releases
[2] root-project#15790
guitargeek added a commit to guitargeek/root that referenced this pull request Dec 1, 2025
The new Keras 3 API broke the existing TMVA `PyKeras` method.

Re-implementing the method for Keras 3 turned out to be difficult, as it
is not possible anymore to disable eager execution and have a decent
speed in evaluating the model for single events. So large-scale
refactoring would be necessary to implement `PyKeras` again with good
performance (see also root-project#15790).

Nowadays, we also have the RBatchGenerator to train Keras models
directly with batches that are provided by ROOT. Therefore, the TMVA
`PyKeras` method is not the only way anymore to train a Keras model with
ROOT data without 3rd party libraries for the IO. That means it's not an
essential feature anymore, and deprecating it will even make the
situation clearer for the user, as there are not two different ways
anymore to train Keras models on ROOT data.
guitargeek added a commit to guitargeek/root that referenced this pull request Jan 4, 2026
The new Keras 3 API broke the existing TMVA `PyKeras` method.

Re-implementing the method for Keras 3 turned out to be difficult, as it
is not possible anymore to disable eager execution and have a decent
speed in evaluating the model for single events. So large-scale
refactoring would be necessary to implement `PyKeras` again with good
performance (see also root-project#15790).

Nowadays, we also have the RBatchGenerator to train Keras models
directly with batches that are provided by ROOT. Therefore, the TMVA
`PyKeras` method is not the only way anymore to train a Keras model with
ROOT data without 3rd party libraries for the IO. That means it's not an
essential feature anymore, and deprecating it will even make the
situation clearer for the user, as there are not two different ways
anymore to train Keras models on ROOT data.
guitargeek added a commit to guitargeek/root that referenced this pull request Jan 4, 2026
The new Keras 3 API broke the existing TMVA `PyKeras` method.

Re-implementing the method for Keras 3 turned out to be difficult, as it
is not possible anymore to disable eager execution and have a decent
speed in evaluating the model for single events. So large-scale
refactoring would be necessary to implement `PyKeras` again with good
performance (see also root-project#15790).

Nowadays, we also have the RBatchGenerator to train Keras models
directly with batches that are provided by ROOT. Therefore, the TMVA
`PyKeras` method is not the only way anymore to train a Keras model with
ROOT data without 3rd party libraries for the IO. That means it's not an
essential feature anymore, and deprecating it will even make the
situation clearer for the user, as there are not two different ways
anymore to train Keras models on ROOT data.
Add support for the new Keras API when using tensorflow 2.16

Note that with the new Keras one needs in pymva to use the ".keras" format
instead of the ".h5" format
…ticlass on all dataset events

Implement the new MethodBase functions GetAllRegressionValues and GetAllMultiClassValues for MethodPyKeras and MethodPyTorch.  This speeds up the model testng and evaluation also for regression and multi-class problems.
Fix also some memory issues with the Python objects used to keep the input/output values in the model evaluation.

Remove timer logging in the pymva GetMultiClassValues functions. The logging is done anyway at the level of MethodBase

Increase statistics and re-add the test on regression error in testPyKerasRegression
@lmoneta lmoneta force-pushed the pymva_support_keras3 branch from 6e3a9d9 to 81ce66b Compare January 12, 2026 10:39
@lmoneta lmoneta requested a review from couet as a code owner January 12, 2026 11:19
Do not use anymore .h5 files but .keras since .h5 is not anymore supported in keras3
@lmoneta lmoneta force-pushed the pymva_support_keras3 branch from 1c1763f to 13b40ca Compare January 12, 2026 15:55
@guitargeek
Copy link
Contributor

Hi, thanks for picking this up again! Could you put tmva-pymva=ON in some Linux CI configs of your choice so we get test coverage of these developments?

@lmoneta lmoneta requested a review from guitargeek January 13, 2026 14:48
Copy link
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you very much! The test failures on alma10 are related to other PyMVA features and SOFIE, so for PyKeras it's all good 👍

2026-01-13T16:45:47.3921839Z TEST FAILURES:
2026-01-13T16:45:47.3922008Z 497:PyMVA-AdaBoost-Classification
2026-01-13T16:45:47.3922208Z 498:PyMVA-AdaBoost-Multiclass
2026-01-13T16:45:47.3922424Z 1442:tutorial-machine_learning-TMVA_SOFIE_RDataFrame-py

Once the temporary test commit changing alma10.txt is removed, the PR is good to be merged!

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
@lmoneta lmoneta force-pushed the pymva_support_keras3 branch from 3b0fe11 to c3956bd Compare January 13, 2026 18:10
@guitargeek
Copy link
Contributor

Looks like some of the PyMVA features don't work on ARM, which is shown on our alma10 ARM build.

Maybe it's fine for you to enable the PyMVA features on another platform, e.g. alma9 instead? For this platform, we don't have an ARM build. Like this, we can already get coverage for tmva-pymva in this PR, and maybe worry about ARM support later (if you don't know an easy fix).

@lmoneta lmoneta force-pushed the pymva_support_keras3 branch from c3956bd to 1414858 Compare January 13, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants