I have Pytorch 2d tensor with normal distribution. Is there a fast way to nullify top 10% max values of this tensor using Python?
I see two possible ways here:
- Flatten tensor to 1d and just sort it
- Non-vectorized way using some native Python operators (for-if)
But neither of these looks fast enough.
So, what is the fastest way to set X max values of a tensor to zero?