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

added UserWarnings if max_epochs not set in the Trainer class #10700

Merged
merged 36 commits into from Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2c6bfea
added UserWarnings if max_epochs not set in the Trainer class
Rajathbharadwaj Nov 23, 2021
e6956fb
updated trainer docs with max_epochs userwarning
Rajathbharadwaj Nov 23, 2021
7830149
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 23, 2021
dd2dc49
implemented suggested change
Rajathbharadwaj Nov 24, 2021
860d758
Update trainer.py
Rajathbharadwaj Nov 24, 2021
aa6ba0a
Merge branch 'max_epoch_userwarning' of https://github.com/Rajathbhar…
Rajathbharadwaj Nov 24, 2021
b61213d
Update trainer.py
Rajathbharadwaj Nov 24, 2021
d4d3de3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
09a14e3
Update trainer.py
Rajathbharadwaj Nov 24, 2021
31b4d3f
changed to rank_zero_warn
Rajathbharadwaj Nov 25, 2021
7add35d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2021
36d069c
refactored with utility
Rajathbharadwaj Nov 26, 2021
e64bc63
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2021
9833956
Update pytorch_lightning/trainer/trainer.py
tchaton Nov 26, 2021
4421b5a
added typing
Rajathbharadwaj Nov 26, 2021
8b742f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2021
af9ae92
implemented suggested change
Rajathbharadwaj Nov 24, 2021
27e8aae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 29, 2021
d184226
Updated with suggested changes
Rajathbharadwaj Nov 29, 2021
2d24f2e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 29, 2021
77c8fac
Update trainer.rst
Rajathbharadwaj Nov 29, 2021
5b30b24
Merge branch 'max_epoch_userwarning' of https://github.com/Rajathbhar…
Rajathbharadwaj Nov 29, 2021
68dbe3d
update
tchaton Nov 30, 2021
3ffa763
add default_max_epochs
tchaton Nov 30, 2021
d3f53f6
add docstring
tchaton Nov 30, 2021
8a0ff60
Update pytorch_lightning/loops/utilities.py
rohitgr7 Dec 4, 2021
7c8d416
Merge branch 'master' into max_epoch_userwarning
rohitgr7 Dec 4, 2021
af308bb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2021
2a0807c
Merge branch 'master' into max_epoch_userwarning
awaelchli Dec 6, 2021
90a90a3
fix bug with access to self.max_epochs etc.
awaelchli Dec 6, 2021
5e82969
format warning
awaelchli Dec 6, 2021
a7d472a
return all settings and update docstring
awaelchli Dec 6, 2021
5b5692b
update changelog
awaelchli Dec 6, 2021
4606cdd
improve warning
awaelchli Dec 6, 2021
e60300c
add test
awaelchli Dec 6, 2021
6ca175b
prevent warning in test
awaelchli Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/common/trainer.rst
Expand Up @@ -900,7 +900,7 @@ Stop training once this number of epochs is reached
# default used by the Trainer
trainer = Trainer(max_epochs=1000)

If both ``max_epochs`` and ``max_steps`` aren't specified, ``max_epochs`` will default to ``1000``.
If both ``max_epochs`` and ``max_steps`` aren't specified, ``max_epochs`` will default to ``1000`` and a ``UserWarning`` will be displayed stating the ``max_epochs`` is not set and defaulted to ``1000``.
rohitgr7 marked this conversation as resolved.
Show resolved Hide resolved
To enable infinite training, set ``max_epochs = -1``.
awaelchli marked this conversation as resolved.
Show resolved Hide resolved

min_epochs
Expand Down
6 changes: 6 additions & 0 deletions pytorch_lightning/trainer/trainer.py
Expand Up @@ -444,6 +444,12 @@ def __init__(
self.signal_connector = SignalConnector(self)
self.tuner = Tuner(self)

# UserWarning for max_epochs if not set

warnings.warn("max_epochs not set, defaulted to 1000 epochs until stop.") if self.max_epochs is None else print(
f"max epochs set to {self.max_epochs}"
)
rohitgr7 marked this conversation as resolved.
Show resolved Hide resolved
rohitgr7 marked this conversation as resolved.
Show resolved Hide resolved

fit_loop = FitLoop(
min_epochs=(1 if (min_epochs is None and min_steps is None and max_time is None) else min_epochs),
max_epochs=(
Expand Down