pytorch-seq2seq icon indicating copy to clipboard operation
pytorch-seq2seq copied to clipboard

Bug with get the embedding from pre-trained model

Open enferas opened this issue 7 years ago • 2 comments

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 avatar Jun 10 '18 16:06 enferas

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

enferas avatar Jun 22 '18 17:06 enferas

@enferas thanks for pointing this out.

pskrunner14 avatar Sep 01 '18 15:09 pskrunner14