-
Notifications
You must be signed in to change notification settings - Fork 966
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
Load pre-trained weights into LookupTable? #746
Comments
Supposed you have |
Thanks, ended up solved it with #747 |
What if the weight tensor is too big and I get cuda out of memory :
The issue is that this tensor has to be allocated twice , once at reading time and once at nn.LookupTable initiatlization. |
@octavian-ganea just convert the weights to float while at reading time, and then at nn.LookupTable you can copy the float weights directly to the cuda module |
@fmassa : In my case I have a 4 million x 100 lookup table, so would like to load pre-initialized weights from a file directly. Currently, I am doing the following:
This is quite slow and occupies twice the memory of a 4M x 100 tensor, since the first line is allocating a huge tensor in memory, and the second one loads another big tensor in memory and afterwards it copies it to m.weight. I would like to have one single huge tensor allocated at a time in memory. Thanks. |
Hi, As a related question, this doesn't seem to work : b = torch.ones(9,5)
l = nn.LookupTable(10,5)
l.weight:narrow(1,2,9):set(b) --unchanged weights Which, I can kinda understand (the reference changes twice). My question is there any easy way of changing a subset of weights without memcopy? |
Just wondering is it possible or practical to load pre-trained weights into
nn.LookupTable
and use it for text classification tasks like sentiment analysis? Thanks.The text was updated successfully, but these errors were encountered: