Lua Torch equivalent of np.where()?

Viewed 1247

I have a ByteTensor and want to grab the indices where there is a 1. In numpy, I could do something like

a = np.array([1,0,1,0,1])
return np.where(a)

which would return (array([0, 2, 4]),). Is this functionality defined in Torch?

(In my particular case, I want to use these indices to index into several different Tensor objects, but it'd be nice to know how to do this in general.)

1 Answers
Related