Skip to content

Commit

Permalink
DOC: Document fit return type change in migration guide (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb authored Apr 10, 2021
1 parent f9f2092 commit 8c031ea
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/source/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ SciKeras is largely backwards compatible with the existing wrappers. For most ca
SciKeras does however have some backward incompatible changes:

Fit returns ``self``
^^^^^^^^^^^^^^^^^^

In TensorFlow calling ``fit`` on wrappers returned a Keras ``History`` object, which held an attribute called ``history`` that is
a dictionary with loss and metric names as keys and lists of recorded values for each epoch as the dictionary values.
However, in SciKeras, ``fit`` now returns and instance of the estimator itself in order to conform to the Scikit-Learn API.
Instead, the history is saved in the ``history_`` attribute.
Calling ``fit`` resets this attribute, calling ``partial_fit`` on the other hand extends it.

.. code:: diff
def get_model():
...
model.compile(loss="mse", metrics=["mae"])
return model
clf = KerasClassifier(get_model)
- hist = clf.fit(...).history
- losses = hist["mae"]
+ hist = clf.fit(...).history_
+ losses = hist["mean_absolute_error"]
.. note::
Unlike the TensorFlow wrappers, SciKeras normalizes the names of the keys, so that if you use `metrics=["mae"]` you will get a key named `"mean_absolute_error"`.

One-hot encoding of targets for categorical crossentropy losses
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down

0 comments on commit 8c031ea

Please sign in to comment.