you can vectorize it: mt = torch.FloatTensor(mean).view(3,1,1), st similar allows you to do img*mt. This is by virtue of the broadcasting implemented in PyTorch. As PyTorch automatically prepends dimensions, it even works if img is a batch of images.
Thanks for the reply. It works fine. In fact, I knew this and also tried it before posting my question here. I thought the problem is with unnormalization but it seems like the problem is something else.