This solution is better. Assume you have a two dimensional tensor y=torch.range(1, 8).reshape(2, 4)
, and x=torch.Tensor([True,False])==True
. In this case, you can’t use torch.masked_select
, but you can easily execute y[x, :]
.
This solution is better. Assume you have a two dimensional tensor y=torch.range(1, 8).reshape(2, 4)
, and x=torch.Tensor([True,False])==True
. In this case, you can’t use torch.masked_select
, but you can easily execute y[x, :]
.