Skip to content

Commit

Permalink
Fix Wrapping optimizers upon assignment (#6006)
Browse files Browse the repository at this point in the history
* Update properties.py

* pep8
  • Loading branch information
justusschock committed Feb 17, 2021
1 parent 68fd308 commit 15d6788
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pytorch_lightning/trainer/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ def optimizers(self) -> Optional[List[Optimizer]]:

@optimizers.setter
def optimizers(self, new_optims: Optional[List[Optimizer]]) -> None:
# Necessary to rewrap optimizers to lightning
# They will be re-created when accessing
# the `lightning_optimizers` trainer property
self._lightning_optimizers = None

self.accelerator.optimizers = new_optims

@property
Expand Down

0 comments on commit 15d6788

Please sign in to comment.