x and y are two matrices. I want to find the indices of nonzero entries in a column of y (let’s say the first column), and take the corresponding rows of x.
In numpy, I can do:
x[y[:,0] > 0]
In theano:
x[(y[:,0]>0).nonzero()]
What is the most appropriate way to do this in Pytorch?
I can do:
m = y[:,0] > 0
x[m.unsqueeze(1).expand_as(x)].resize(m.long().sum().data[0], x.size()[1])
But I assume there should be a much easier way.
Thanks.