Skip to content
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

Lookahead has no attribute 'state' #3

Open
HJ-harry opened this issue Oct 2, 2019 · 5 comments
Open

Lookahead has no attribute 'state' #3

HJ-harry opened this issue Oct 2, 2019 · 5 comments

Comments

@HJ-harry
Copy link

HJ-harry commented Oct 2, 2019

When trying to save optimizer_state_dict,
I get an error saying >>Lookahead has no attribute 'state'
I thought this was due to not initializing parent class inside the class Lookahead
and so I added the line

super(Lookahead).__init__()

However, this still does not solve the issue. Other than saving, there seems no issue. Do you have any idea how to solve this issue?

@Kyeongpil
Copy link

I got same problem...

@Kyeongpil
Copy link

@HJ-harry Do you use horovod?

It happens when I use horovod.

I solved the problem by changing the position of warpping.

ex)
base_optimizer = Adam()
base_optimizer = hvd.DistributedOptimizer(base_optimizer, named_parameters=...)
hvd.broadcast_parameters(model.state_dict(), root_rank=0)
hvd.broadcast_optimizer_state(base_optimizer, root_rank=0)
optimizer = Lookahead(base_optimizer, k=5, alpha=0.5)

@Kyeongpil
Copy link

Kyeongpil commented Oct 26, 2019

I got a same error when saving the Lookahead optimizer.
Lookahead optimizer should have the state_dict function.

@oscardssmith
Copy link

I just ran into this too. Any fixes?

@cozek
Copy link

cozek commented Mar 3, 2020

@oscardssmith optimizer.optimizer.state_dict() seems to solve the issue for me. But i still think, there should be a state for the entire optimizer as whole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants