Float64 Normalisation in pytorch
So when I want to do normalization to float64 in deep learning, I need to make float64_max to be 1 or just every image’s max value as 1?
I read a .nii file to get a 3D array with type float64 and its value is very big. I need to normalize it into 0-1 and float32 type to input my deep learning model. So I was wondering which normalization way is better or correct.
Make float64_max to be 1:
return torch.tensor(img / sys.float_info.max).to(torch.float32)

Make every image's max value as 1:
return torch.nn.functional.normalize(torch.tensor(img)).to(torch.float32)

Also, because the float64 range is much bigger than float32, when I do return torch.tensor(img / sys.float_info.max).to(torch.float32), the value have a chance to be all 0.

No, you should normalize the max possible value of all images to 1 not the maximum value of each image separately.
For a general image RGB 8-bit image, the maximum value for a pixel channel is 255, so you could divide the entire image's channel value by 255.
In this way, you will obtain a new image of type float32 (or float64) with all pixel's channel values in the range [0, 1], but the min is not always 0 and max is not always 1.
