-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Editing issue with pickle def with lambda function #23869
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,6 +32,21 @@ | |||||
logger = logging.get_logger(__name__) | ||||||
|
||||||
|
||||||
def get_constant_lambda(_=None): | ||||||
""" | ||||||
Return 1, independent from args. | ||||||
|
||||||
Args: | ||||||
_ ( *optional*, defaults to None): | ||||||
Placeholder to argument, used to consistency with args in LambdaLR | ||||||
|
||||||
Return: | ||||||
1 : int - constant lambda for constant scheduler | ||||||
""" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for a documentation for a private function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete it. |
||||||
|
||||||
return 1 | ||||||
|
||||||
|
||||||
def get_constant_schedule(optimizer: Optimizer, last_epoch: int = -1): | ||||||
""" | ||||||
Create a schedule with a constant learning rate, using the learning rate set in optimizer. | ||||||
|
@@ -46,7 +61,7 @@ def get_constant_schedule(optimizer: Optimizer, last_epoch: int = -1): | |||||
`torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule. | ||||||
""" | ||||||
|
||||||
return LambdaLR(optimizer, lambda _: 1, last_epoch=last_epoch) | ||||||
return LambdaLR(optimizer, get_constant_lambda, last_epoch=last_epoch) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done refactoring based on function name |
||||||
|
||||||
|
||||||
def get_reduce_on_plateau_schedule(optimizer: Optimizer): | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.