Closed lunjiaqi closed 6 years ago
idx_sort = torch.from_numpy(idx_sort).cuda() if self.is_cuda() \ else torch.from_numpy(idx_sort) sent = sent.index_select(1, Variable(idx_sort))
what should I modify? Thanks!
Hi,
could you launch the debugger here: https://github.com/facebookresearch/InferSent/blob/master/models.py#L50 and check what is the value returned by "is_cuda()", in particular what is "str(type(self.enc_lstm.bias_hh_l0.data))" in your case? Thanks!
OK,thanks!I have a try!
@lunjiaqi I replaced
return 'cuda' in str(type(self.enc_lstm.bias_hh_l0.data))
with
return self.enc_lstm.bias_hh_l0.data.is_cuda
Committed the change suggested by jsedoc. The bug came from the change to the new pytorch version.
This project do not support training anymore. So do you know a better code for sentence embedding? Thank you!
Traceback (most recent call last): File "train_nli.py", line 291, in
train_acc = trainepoch(epoch)
File "train_nli.py", line 179, in trainepoch
output = nli_net((s1_batch, s1_len), (s2_batch, s2_len))
File "/home/zjt2/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, *kwargs)
File "/mnt/merry/zjt2/jiaqi/InferSent/models.py", line 826, in forward
u = self.encoder(s1)
File "/home/zjt2/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(input, **kwargs)
File "/mnt/merry/zjt2/jiaqi/InferSent/models.py", line 64, in forward
sent = sent.index_select(1, Variable(idx_sort))
RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index'