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

fixed issue of passing empty parameter list to optimizer #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

prschoenfelder
Copy link

@prschoenfelder prschoenfelder commented Jan 21, 2021

Hi @Andras7, first I want to thank you for providing this code, it really is a big help. I ran into this error when trying to train the model:

Traceback (most recent call last):
File "/path/to/test.py", line 8, in
w2v_trainer.train()
File "/path/to/venv/lib/python3.8/site-packages/word2vec/trainer.py", line 37, in train
optimizer = optim.SparseAdam(self.skip_gram_model.parameters(), lr=self.initial_lr)
File "/path/to/venv/lib/python3.8/site-packages/torch/optim/sparse_adam.py", line 49, in init
super(SparseAdam, self).init(params, defaults)
File "/path/to/venv/lib/python3.8/site-packages/torch/optim/optimizer.py", line 47, in init
raise ValueError("optimizer got an empty parameter list")
ValueError: optimizer got an empty parameter list

So I went ahead and wrapped self.skip_gram_model.parameters() in list().
Might this be a version issue? I ran it with python=3.8, torch=1.7.1

Works for me now, hope this is fine with you? Feel free to accept the PR.

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

Successfully merging this pull request may close these issues.

1 participant