Solved by Nikronic in post #4 
              
              
                This may help: 
min = float(img.min())
max = float(img.max())
img.clamp_(min=min, max=max)
img.add_(-min).div_(max - min + 1e-5)


Even a simpler way would be using torchvision.utils.save_image