Keras - 4th dimension

270 views Asked by At

I am using Keras included models. For example, let's take ResNet50:

model = keras.applications.resnet50.ResNet50(include_top=True, 
                                     weights='imagenet',
                                     classes=1000)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy')

from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
        'data/animals/',  
        target_size=(244, 244),
        batch_size=1
)

model.fit_generator(generator=train_generator, steps_per_epoch=100, epochs=3)

And getting the error:

Error when checking input: expected input_1 to have shape (None, 224, 224, 3) but got array with shape (1, 244, 244, 3)

How am I supposed to integrate Resnet50 with the Image Generator, when even the fit_generator function can't work with generator?

How can I set fourth dimension to None?

0

There are 0 answers