Solved by ptrblck in post #5 
              
              
                I’m not sure what your shapes are, but could this work? 
a = torch.randn(3, 2)
th = torch.randn(3, 1)

print(a)
> tensor([[ 1.1200, -0.1365],
        [-0.1328,  0.0842],
        [-0.5945,  0.6210]])
print(th)
> tensor([[-0.7215],
        [ 1.1406],
        [-0.4683]])

idx = (a > th).float()
print(a…