Hi,
I training a GAN model. So the input image is normalized to a mean say x and std say y. What is the best way to un-normalize the generated image
It depends, how you’ve applied the normalization.
If you’ve used a standardization approach such as:
x = torch.empty(1, 3, 224, 224).uniform_(0, 255)
mean = x.mean([0, 2, 3], keepdim=True)
std = x.std([0, 2, 3], keepdim=True)
x_norm = (x - mean) / std
then you could simply reverse it via:
x_re = x_norm * std + mean
print((x - x_re).abs().max())
> tensor(1.5259e-05)
1 Like