scikeras icon indicating copy to clipboard operation
scikeras copied to clipboard

Keras 3 support

Open jamesmyatt opened this issue 1 year ago • 4 comments

Does SciKeras work with Keras 3, which was released recently? https://keras.io/keras_3/

Are there any changes that might need to be made to SciKeras? https://keras.io/guides/migrating_to_keras_3/

jamesmyatt avatar Mar 18 '24 11:03 jamesmyatt

Don't think it's working with keras 3, getting the following error with keras==3.0.5 scikeras==0.12.0 scikit-learn==1.4.1.post1 tensorflow==2.16.1

Expected: No Exception to be thrown
  But was:  <Python.Runtime.PythonException: Could not interpret metric identifier: loss
  File "/opt/miniconda3/lib/python3.11/site-packages/keras/src/metrics/__init__.py", line 204, in get
    raise ValueError(f"Could not interpret metric identifier: {identifier}")
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/utils/__init__.py", line 111, in metric_name
    fn_or_cls = keras_metric_get(metric)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/wrappers.py", line 531, in _fit_keras_model
    key = metric_name(key)
          ^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/wrappers.py", line 536, in _fit_keras_model
    raise e
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/wrappers.py", line 928, in _fit
    self._fit_keras_model(
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/wrappers.py", line 760, in fit
    self._fit(
  File "/opt/miniconda3/lib/python3.11/site-packages/scikeras/wrappers.py", line 1491, in fit
    super().fit(X=X, y=y, sample_weight=sample_weight, **kwargs)

Martin-Molinero avatar Mar 18 '24 17:03 Martin-Molinero

It is not compatible right now but I think getting it compatible with Keras v3 (and doing cleanup along the way) would be a good milestone.

adriangb avatar Mar 18 '24 18:03 adriangb

That would be great. Keras 3 should increase interest in Keras again, so it would be a great help to have this.

jamesmyatt avatar Mar 18 '24 18:03 jamesmyatt

I started working on this: https://github.com/keras-team/keras/pull/19352

adriangb avatar Mar 21 '24 14:03 adriangb

Could you please try #317 (pip install -U 'git+https://github.com/adriangb/scikeras.git@keras-3') and see if it fixes your problem? Thanks!

adriangb avatar Apr 07 '24 14:04 adriangb

This should be fixed now. Please let me know if this is still not fixed with SciKeras 0.13.0. Thanks!

adriangb avatar Apr 15 '24 18:04 adriangb