I am trying to remove the structure in images (say a 28x28 MNIST digit image) while keeping the distribution of each pixel the same. To achieve this I need to independently permute each pixel along the batch dimension. I could use torch.randperm to shuffle the indices for each pixel or numpy.random.permutation to do the permutation directly. However both of these functions only operate on the first dimension of the tensor which means I would need to run them in a 28x28 for loop.
Is there a more computationally efficient way to do this?