Value Error while fitting tensorflow model

  Kiến thức lập trình

I create a iterator using:

tensorflow.keras.preprocessing.image.ImageDataGenerator


training_iterator = ImageDataGenerator(rescale=1/255)
training_iterator.flow_from_directory('./Covid19-dataset/train', class_mode='categorical', color_mode='grayscale', target_size= (256,256), batch_size=20)
validation_iterator = ImageDataGenerator(rescale=1/255)
validation_iterator.flow_from_directory('./Covid19-dataset/test', class_mode='categorical', color_mode='grayscale', target_size= (256,256), batch_size=20)

and when I try to fit it it throws a error

model.fit(training_iterator,validation_data= validation_iterator)

ValueError: Unrecognized data type: x=<keras.src.legacy.preprocessing.image.ImageDataGenerator object at 0x000002E7B7EECF50> (of type <class 'keras.src.legacy.preprocessing.image.ImageDataGenerator'>)

I expect that code runs without any errors cause I had previously fit model on iterator object but IDK what’s the problem.

New contributor

Amir Ahmadihagh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT