I'm again struggling with the usage of tensorflow datasets. I'm again loading my images via
data = keras.preprocessing.image_dataset_from_directory(
'./data',
labels='inferred',
label_mode='binary',
validation_split=0.2,
subset="training",
image_size=(img_height, img_width),
batch_size=sz_batch,
crop_to_aspect_ratio=True
)
I want to use this dataset in the pre-trained MobileNetV2
model = keras.applications.mobilenet_v2.MobileNetV2(input_shape=(img_height, img_width, 3), weights='imagenet')
The documentation says, that the input data must be scaled to be between -1 and 1. To do so, the preprocess_input function is provided. When I use this function on my dataset
scaled_data = tf.keras.applications.mobilenet_v2.preprocess_input(data)
I get the error: TypeError: unsupported operand type(s) for /=: 'BatchDataset' and 'float'
So how can I use this function properly with the tensorflow dataset?


