Skip to content

Commit

Permalink
Do not cache lr_scheduler_name
Browse files Browse the repository at this point in the history
  • Loading branch information
andrrizzi authored Dec 22, 2023
1 parent 352b943 commit 28c2e1b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mlcolvar/cvs/cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
# OPTIM
self._optimizer_name = "Adam"
self.optimizer_kwargs = {}
self._lr_scheduler_name = None
self.lr_scheduler_kwargs = {}

# PRE/POST
Expand Down Expand Up @@ -202,9 +201,9 @@ def configure_optimizers(self):
)

if self.lr_scheduler_kwargs:
if self._lr_scheduler_name is None:
self._lr_scheduler_name = self.lr_scheduler_kwargs.pop('scheduler')
lr_scheduler = self._lr_scheduler_name(optimizer, **self.lr_scheduler_kwargs)
scheduler_cls = self.lr_scheduler_kwargs['scheduler']
scheduler_kwargs = {k: v for k, v in self.lr_scheduler_kwargs.items() if k != 'scheduler'}
lr_scheduler = scheduler_cls(**scheduler_kwargs)
return [optimizer] , [lr_scheduler]
else:
return optimizer
Expand Down

0 comments on commit 28c2e1b

Please sign in to comment.