8000 torch.multinomial can't be used without allocating memory · Issue #359 · torch/torch7 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

torch.multinomial can't be used without allocating memory #359

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 8000 send you account related emails.

Already on GitHub? Sign in to your account

Closed
adria-p opened this issue Sep 11, 2015 · 3 comments
Closed

torch.multinomial can't be used without allocating memory #359

adria-p opened this issue Sep 11, 2015 · 3 comments

Comments

@adria-p
Copy link
adria-p commented Sep 11, 2015

The docs mention that the function can be used as torch.multinomial([res,], p, n, [,replacement]) but calling torch(res, p, n) does not seem to work, it simply fails mentioning that torch.LongTensor does not implement torch.multinomial.

@fmassa
Copy link
Contributor
fmassa commented Sep 11, 2015

This is a similar problem than the one mentioned in #231 , because the output of multinomial is supposed to be a LongTensor, and when you call it with torch.multinomial it looks for the type of it's first argument (which is a LongTensor), but multinomial expects p to be FloatTensor or DoubleTensor.

But there is actually a workaround for this, which is to call it as p.multinomial(res,p,n,[replacement]). This way, you explicitly specify that you want to call it for the type of tensor p.

@adria-p
Copy link
Author
adria-p commented Sep 11, 2015

That indeed works as a workaround, thanks!

soumith added a commit that referenced this issue Oct 4, 2015
@soumith
Copy link
Member
soumith commented Oct 4, 2015

Added doc for the issue, via commit: 656a4a2

@soumith soumith closed this as completed Oct 4, 2015
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

3 participants
0