Skip to content

[tmva][sofie] Improve Keras test robustness and diagnostics#21749

Open
guitargeek wants to merge 1 commit intoroot-project:masterfrom
guitargeek:keras_tests
Open

[tmva][sofie] Improve Keras test robustness and diagnostics#21749
guitargeek wants to merge 1 commit intoroot-project:masterfrom
guitargeek:keras_tests

Conversation

@guitargeek
Copy link
Copy Markdown
Contributor

@guitargeek guitargeek commented Mar 30, 2026

This is a spinoff from my Python dev mode PR:

Who knows, maybe the errors on alma8 with NumPy 2.4.4 go away with this, or at least we get some more informative errors! And even if not, this is a good improvement that allows us to run the test with python -W error, which is what I plan generally to do in the CI.

What is already clear from the NumPy warnings is that somehow TensorFlow/Keras doesn't implement the __array__ interface correctly as NumPy 2 expects.

  * Skip training for models without trainable weights to avoid spurious
    Keras warnings about "no trainable weights"

  * Suppress NumPy 2.0 __array__ DeprecationWarning during model.save()
    (upstream TF/Keras compatibility issue) using a scoped warnings context

  * Fix Keras inference call for single-input models by unwrapping
    singleton input lists (Keras expects a tensor, not [tensor])

  * Remove redundant load_weights() after load_model()

  * Replace custom is_accurate() with np.testing.assert_allclose()
    for clearer diagnostics and standardized comparison
    * use atol=1e-2 and rtol=0 to preserve previous absolute tolerance behavior

  * Update LeakyReLU argument (alpha -> negative_slope) to avoid
    deprecation warnings

These changes make the tests more robust, reduce noise from external
dependencies, and significantly improve failure diagnostics.
@github-actions
Copy link
Copy Markdown

Test Results

    21 files      21 suites   2d 23h 13m 16s ⏱️
 3 832 tests  3 830 ✅  1 💤 1 ❌
73 042 runs  73 022 ✅ 18 💤 2 ❌

For more details on these failures, see this check.

Results for commit c4df112.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant