Skip to content

Fix the NN code for Keras 3 and scikit-learn 1.4+ - #8

Merged
adimajo merged 4 commits into
masterfrom
fix/keras3-nn
Oct 31, 2026
Merged

adimajo merged 4 commits into
masterfrom
fix/keras3-nn

Conversation

@adimajo

@adimajo adimajo commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Second stream. Stacked on #7 (base is fix/correctness-bugs); retarget to
master once #7 is merged.

With current TensorFlow (Keras 3) and scikit-learn, every NN fit raised before
training: 24 tests of tests/tests_NN failed on master. This makes them run
again, one fix per commit:

  • the default RMSprop optimizer is built with learning_rate and Keras'
    default epsilon (lr, decay and epsilon=None are gone);
  • tf.keras.backend.function no longer exists, so layer outputs are computed
    by calling the layers through a small _layer_output helper that keeps the
    list shape the callers index into;
  • OneHotEncoder(sparse=False) becomes sparse_output=False;
  • test_kwargs compares against the public Keras classes instead of
    tensorflow.python.

Tests: 93 pass, including all NN tests (about 3 minutes, the NN tests train).

RMSprop no longer accepts lr, decay or epsilon=None, so every NN fit
raised before training started. Use learning_rate and Keras' default
epsilon, which is what epsilon=None used to select.
tf.keras.backend.function does not exist in Keras 3. Compute the layer
outputs by calling the layers directly, through a helper that keeps the
list-of-outputs shape the callers index into.
scikit-learn 1.4 removed the sparse argument of OneHotEncoder, which
made the evaluation of every NN epoch raise TypeError.
test_kwargs compared the optimizer and callback to classes living in
tensorflow.python, a private path that Keras 3 removed. Compare with the
classes the test imports from tensorflow.keras instead.
@adimajo
adimajo changed the base branch from fix/correctness-bugs to master October 29, 2026 21:35
@adimajo
adimajo merged commit 4c0ea24 into master Oct 31, 2026
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.

1 participant