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

did it doenst need backpropagation process? #4

Open
qyccc opened this issue Sep 2, 2021 · 4 comments
Open

did it doenst need backpropagation process? #4

qyccc opened this issue Sep 2, 2021 · 4 comments

Comments

@qyccc
Copy link

qyccc commented Sep 2, 2021

I dont find any backpropagation process in the code. I'm curious about how the stochastic embedding be optimized. I wonder Am I misunderstanding the paper or the code is uncompeleted? Thanks for answer my question

@ghost
Copy link

ghost commented Sep 6, 2021

Yes, I find this problem too. When updating the model, the learned embedding remains unchanged ! I also wonder how to update the soft embedding...

@ekoenitz
Copy link

ekoenitz commented Nov 3, 2021

I'd also like to know this. As-is it looks like the code just feeds the original embedding (or another model's embedding) back into the model, which doesn't sound right.

@kipgparker
Copy link
Owner

PyTorch handles all the backpropagation process, you just need to specify which parameters you want to update.

model.set_input_embeddings(s_wte)
#after updating the embedding, specify that you want to train the learned embedding
optimizer = optim.Adam([model.transformer.wte.learned_embedding])

Also, I'm not passing a reference to the original embedding, just initializing the learning embedding to the original embedding and cloning the weights (hopefully for a better initialization), the paper does it somewhat differently, but I think it's the same idea.

@hguan6
Copy link

hguan6 commented Nov 11, 2021

I think it is better to freeze some parameters to reduce gradient computations. Use something like https://discuss.huggingface.co/t/how-to-freeze-layers-using-trainer/4702/3

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