0

我正在使用 Keras 包含的模型。以 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)

并得到错误:

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

fit_generator当即使该功能无法与生成器一起使用时,我应该如何将 Resnet50 与图像生成器集成?

如何将第四维设置为None

4

0 回答 0