Indexing a Variable with a mask generated from another Variable
x[y[:,0] > 0] But I assume there should be a much easier way. Thanks.
yusuf_isik
Yeah, we’ve added the ability to select based on the long tensor a few days ago. I think it’s in the new binaries, so once you reinstall pytorch this should work: <SCODE>x[(y[:, 0] > 0).nonzero().squeeze()]
<ECODE>
apaszke
And in the future, we’re going to support automatic broadcasting so the numpy way should work in some time too.
apaszke
That’s very good news. Thanks.
yusuf_isik
I just reinstalled from scratch , but it cannot find nonzero() function. I am getting the following message: I also have a version that I built from source, and I get the same error from it, too. How can I get the right version? Thanks.
yusuf_isik
apaszke
Four months passed, we still can not use nonzero() for Variables…
acgtyrant
You can always open an issue in the main repo
apaszke