有时候在程序中需要对图像做可视化,但是读取进来的tensor已经经过了normalization,为小数,甚至可能出现负值
为了可视化图像,必须对将tensor通过逆标准化获得原始的tensor
具体方法参考 [Feature Request] Un-Normalize Image Tensor
mean = torch.tensor([1, 2, 3], dtype=torch.float32) std = torch.tensor([2, 2, 2], dtype=torch.float32) normalize = T.Normalize(mean.tolist(), std.tolist()) unnormalize = T.Normalize((-mean / std).tolist(), (1.0 / std).tolist())


![[PyTorch] reverse the normalization [PyTorch] reverse the normalization](http://www.mshxw.com/aiimages/31/714421.png)
