Hello!
I was writing a transfer learning model where I wanted to do preprocessing and take input images so i wrote the following code
train_batches = ImageDataGenerator().flow_from_directory(train_path,target_size=(224,224),batch_size=10)
valid_batches = ImageDataGenerator().flow_from_directory(valid_path,target_size=(224,224),batch_size=30)
test_batches= ImageDataGenerator().flow_from_directory(test_path,target_size=(224,224), batch_size=50, shuffle=False)
I proceeded to write the entire model and it ran successfully
However I then realised that from_from_directory is deprecated and we are required to use
image_from_dataset instead
So I tried to write the equivalent code for it ( Below)
train_dataset = tf.keras.preprocessing.image_dataset_from_directory(train_path, image_size=(224, 224), batch_size=10)
# valid_dataset = tf.keras.preprocessing.image_dataset_from_directory(valid_path, image_size=(224, 224), batch_size=30)
# test_dataset = tf.keras.preprocessing.image_dataset_from_directory(test_path, image_size=(224, 224), batch_size=50, shuffle=False)
However this time while training the model, it is giving the following error
target.shape.assert_is_compatible_with(output.shape)
ValueError: Shapes (None, 1) and (None, 10) are incompatible
How to recitfy this?