Skip to content

Adding TimeStopping to tfa.callback #757

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

Merged
merged 4 commits into from
Dec 15, 2019
Merged

Adding TimeStopping to tfa.callback #757

merged 4 commits into from
Dec 15, 2019

Conversation

shun-lin
Copy link
Contributor

This PR adds TimeStopping to tfa.callback. Similar to EarlyStopping but stops the training when a specified amount of time has passed since the start of the training.

This may be useful for people who want to train a model for a certain amount of time. Personally, sometimes I would want to train models for a certain amount of time (and there are codes after training ends so CTRL+C is not ideal) and I often find myself using pen and pencil to calculate how many epochs I would want to run. I hope people may find this useful as well.

Relevant Issues:
#750
keras-team/keras#1625
keras-team/keras-contrib#87

Thank you so much for your time!

@shun-lin shun-lin requested review from Squadrick and a team as code owners December 12, 2019 09:31
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB.

@shun-lin
Copy link
Contributor Author

@seanpmorgan when you have a chance may you review this PR? Thank you so much for your time!

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

Looks very good. Please see comments

Args:
seconds: maximum amount of time before stopping.
Defaults to 86400 (1 day).
verbose: verbosity mode. Defaults to 0.
Copy link
Member

@seanpmorgan seanpmorgan Dec 13, 2019

Choose a reason for hiding this comment

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

Is there a reason for using an int here instead of a boolean? Doesn't seem like varying verbosity values will make any difference, so better to prevent that confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use int here for consistency with EarlyStopping Callback.
https://github.com/tensorflow/tensorflow/blob/r2.0/tensorflow/python/keras/callbacks.py#L1134-L1251
And I would assume they also use int instead of just boolean is so that it is consistent with other places that has verbose as a parameter. This is my reasoning (for consistency), but if you feel like changing to boolean is better let me know! Thanks for the feedback!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. Still feels a little intuitive, but I agree better to stay with the convention.

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

Small lint fix needed:
tensorflow_addons/callbacks/time_stopping.py:53: [C0301(line-too-long), ] Line too long (80/79)

@shun-lin
Copy link
Contributor Author

Small lint fix needed:
tensorflow_addons/callbacks/time_stopping.py:53: [C0301(line-too-long), ] Line too long (80/79)

ops, got it will fix!

@shun-lin
Copy link
Contributor Author

Small lint fix needed:
tensorflow_addons/callbacks/time_stopping.py:53: [C0301(line-too-long), ] Line too long (80/79)

fixed!

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

LGTM thanks again for the contribution!

@seanpmorgan seanpmorgan merged commit 0228bc5 into tensorflow:master Dec 15, 2019
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.

4 participants