Question regarding image grid

What is the function of the following line of code?

image_tensor = (image_tensor + 1) / 2

It is normalization. I assume the images were normalized to [-1, 1] (the generator usually outputs images in this range due to the tanh activation) and this line of code normalizes them to [0, 1] (in order to save or plot them).

1 Like