I need to use keras.preprocessing.image_dataset_from_directory() for a large dataset. My GPU is RTX so I would also like to use mixed precision training in Tensorflow 2.5.
How do I cast the output images of the generator to float16? I've tried the .cast() method with no success. I'd also like to avoid generic scaling as I want to rigidly control normalisation factors and if possible scale my images from -1 to 1 with a uniform (2*x/255)-1 where x is the image. I also tried to pass a straight np.float16() in that scaling function applied to the TF dataset. No success either. What am I missing?