Simple way to inverse transform ? Normalization

A slightly modified version of the above code

This suppose a defined mean and std.

inv_normalize = transforms.Normalize(
   mean= [-m/s for m, s in zip(mean, std)],
   std= [1/s for s in std]
)

inv_tensor = inv_normalize(tensor)
3 Likes