facebookresearch / SentEval

A python tool for evaluating the quality of sentence embeddings.
Other
2.09k stars 309 forks source link

fix issue #9 bow.py RuntimeError: tried to construct a tensor from a … #11

Closed sojvai closed 7 years ago

sojvai commented 7 years ago

fix issue #9

It seems cuda tensor doesn't accept numpy array as a parameter. convert it to python list worked.

facebook-github-bot commented 7 years ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

facebook-github-bot commented 7 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

aconneau commented 7 years ago

Could you try

idx = torch.from_numpy(permutation[i:i + self.batch_size]).long().cuda()

instead and let me know if that fixes the issue? I think it would make more sense to use the "from_numpy" function here.

sojvai commented 7 years ago

Yeah. That worked!

sojvai commented 7 years ago

@aconneau updated the PR based on your suggestion.

aconneau commented 7 years ago

Thanks! There may be other lines like this that are not pytorch 0.2 compatible. I'll merge your pull request and track the rest myself.