From 4ca330d427d38dcae78371f0615a37d4e891d539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dyczko?= <48859012+michaldyczko@users.noreply.github.com> Date: Wed, 29 May 2024 09:17:15 +0200 Subject: [PATCH 1/2] fix: change Lookahead's param_groups to a property #fixes kozistr/pytorch_optimizer#237 --- pytorch_optimizer/optimizer/lookahead.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pytorch_optimizer/optimizer/lookahead.py b/pytorch_optimizer/optimizer/lookahead.py index 507971f2c..6f3be06da 100644 --- a/pytorch_optimizer/optimizer/lookahead.py +++ b/pytorch_optimizer/optimizer/lookahead.py @@ -36,7 +36,6 @@ def __init__( self.pullback_momentum = pullback_momentum self.optimizer = optimizer - self.param_groups = self.optimizer.param_groups self.state: STATE = defaultdict(dict) @@ -58,6 +57,10 @@ def __init__( **optimizer.defaults, } + @property + def param_groups(self): + return self.optimizer.param_groups + def __getstate__(self): return { 'state': self.state, From 25b4f2024417558793b9899cc434da1e621765a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dyczko?= Date: Wed, 29 May 2024 13:50:05 +0200 Subject: [PATCH 2/2] style: remove unnecessary whitespace in Lookahead class --- pytorch_optimizer/optimizer/lookahead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_optimizer/optimizer/lookahead.py b/pytorch_optimizer/optimizer/lookahead.py index 6f3be06da..6e149f0f4 100644 --- a/pytorch_optimizer/optimizer/lookahead.py +++ b/pytorch_optimizer/optimizer/lookahead.py @@ -60,7 +60,7 @@ def __init__( @property def param_groups(self): return self.optimizer.param_groups - + def __getstate__(self): return { 'state': self.state,