-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
βπ Fix (Re-)Instantiation of LR-Schedule (#1386)
Fix #1384 Also, do not register an LR scheduler callback if we do not have a learning rate scheduler, instead of just doing nothing in the callback. --------- Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
- Loading branch information
Showing
3 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Tests for LR schedulers.""" | ||
|
||
import pytest | ||
from class_resolver import HintOrType, OptionalKwargs | ||
from torch.optim import lr_scheduler | ||
|
||
from pykeen.pipeline import pipeline | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"cls, kwargs", | ||
[ | ||
(None, None), | ||
("CosineAnnealingWarmRestarts", None), | ||
("CosineAnnealingWarmRestarts", {"T_0": 10}), | ||
], | ||
) | ||
def test_lr_scheduler(cls: HintOrType[lr_scheduler.LRScheduler], kwargs: OptionalKwargs) -> None: | ||
"""Smoke-test for training with learning rate schedule.""" | ||
pipeline( | ||
dataset="nations", | ||
model="mure", | ||
model_kwargs=dict(embedding_dim=2), | ||
training_kwargs=dict(num_epochs=1), | ||
lr_scheduler=cls, | ||
lr_scheduler_kwargs=kwargs, | ||
) |