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

Bug with get the embedding from pre-trained model #147

Open
enferas opened this issue Jun 10, 2018 · 2 comments
Open

Bug with get the embedding from pre-trained model #147

enferas opened this issue Jun 10, 2018 · 2 comments

Comments

@enferas
Copy link

enferas commented Jun 10, 2018

Hello,

I was trying to to use pre-trained model for the embedding but there are two bugs.

The first one in the sample.py, with init the parameters. I think we shouldn't init the embedding.
for param in seq2seq.parameters(): param.data.uniform_(-0.08, 0.08)
I recommend to be like that
for param in [p for p in seq2seq.parameters() if p.requires_grad == True]: param.data.uniform_(-0.08, 0.08)

The second bug is with the optimization in supervised_trainer.py, that the optimization will throw an error when we will try to optimize the embedding.
optimizer = Optimizer(optim.Adam(model.parameters()), max_grad_norm=5)
I will recommend to be like that.
optimizer = Optimizer(optim.Adam(filter(lambda p: p.requires_grad, model.parameters())), max_grad_norm=5)

I have a question, do you thing it is important to have the pre-trained embedding in the decoder either or just in the encoder will be enough ?

@enferas
Copy link
Author

enferas commented Jun 22, 2018

The same error with the resume option. should be
self.optimizer.optimizer = resume_optim.__class__(filter(lambda p: p.requires_grad, model.parameters()), **defaults)

@pskrunner14
Copy link

@enferas thanks for pointing this out.

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

No branches or pull requests

2 participants