I noticed an improvement by doing per-channel normalization (6-channel images). It would be nice to simply use scikit-learn’s scalers like MinMaxScaler, but I noticed it’s much slower. The code for doing it is (inside __getitem__):
scaler = MinMaxScaler()
for i in range(img.size()[0]):
    img[i] = torch.tensor(scaler.fit_transform(img[i]))

I tried to code it myself using PyTorch. For the MinMaxScaler I wrote:
class MinMaxScaler(object):
    """
    Transforms each channel to the range [0, 1].
    """
    
    def __call__(self, tensor):
        
        for ch in tensor:
            scale = 1.0 / (ch.max() - ch.min())
            ch.mul_(scale).sub_(ch.min().mul_(scale))
        
        return tensor

The problem is that I do not obtain the same results as the original scaler. Do you spot anything wrong in my code? Is per-channel scaling implemented already in torchvision?