Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with new keras Callback model #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ali-tny
Copy link

@ali-tny ali-tny commented May 28, 2020

see https://keras.io/guides/writing_your_own_callbacks/ for guide - methods have been split to provide a different one for train/eval/predict time.

This change translates on_batch_end to on_train_batch_end rather than also for validation batches, so batch history only includes train batch loss - not sure if you wanna include the validation batches in the history here for plotting? Would just need to set on_test_batch_end to the same as on_train_batch_end.

@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #5 into master will increase coverage by 31.77%.
The diff coverage is 54.54%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #5       +/-   ##
===========================================
+ Coverage   22.77%   54.54%   +31.77%     
===========================================
  Files           3        3               
  Lines         101      121       +20     
===========================================
+ Hits           23       66       +43     
+ Misses         78       55       -23     
Impacted Files Coverage Δ
kerashistoryplot/callbacks.py 59.67% <54.54%> (+59.67%) ⬆️
kerashistoryplot/plot.py 17.14% <0.00%> (+17.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a13745...5d9eb03. Read the comment docs.

Copy link
Owner

@ig248 ig248 left a comment

Choose a reason for hiding this comment

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

Could you indicate what versions of keras the old vs new api would be compatible to? Also, maybe update the Callback docstring - tbh the only reason the base class is here is to avoid importing it from keras, hence avoiding keras as a dependency. However, if there are API differences, we could specify a keras version range in the setup.py?

@ali-tny ali-tny force-pushed the update-for-new-keras branch from 6d5ac85 to dcc4ec5 Compare June 2, 2020 03:07
@ali-tny
Copy link
Author

ali-tny commented Jun 2, 2020

I've updated to be backwards compatible (much like tensorflow.keras does). I considered just adding the keras dependency and importing the Callback base class, but to install tf.keras it needs all of tensorflow, and it seems kinda heavyweight now that its compatible across versions.

I also added a test - it requires adding matplotlib & ipython as dev dependencies though so it can import kerasplothistory.callbacks

@ali-tny ali-tny requested a review from ig248 June 2, 2020 03:09
@ali-tny ali-tny force-pushed the update-for-new-keras branch from dcc4ec5 to 6e999b2 Compare June 2, 2020 03:10
ali.teeney added 3 commits June 2, 2020 13:21
typeshed was recently removed from PyPI (and comes bundled with mypy
anyway) so was causing dependency resolution to fail.
see https://keras.io/guides/writing_your_own_callbacks/ for guide -
methods have been split to provide a different one for
train/eval/predict time.

This change translates `on_batch_end` to `on_train_batch_end` rather
than also for validation batches, so batch history only includes train
batch loss.
@ali-tny ali-tny force-pushed the update-for-new-keras branch from 6e999b2 to 5d9eb03 Compare June 2, 2020 03:22
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.

2 participants