我正在使用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
?