train_data = ImageDataGenerator(rescale=1./255)
test_data = ImageDataGenerator(rescale=1./255)
train_set = train_data.flow_from_directory('train_set',
target_size=(28,28),
batch_size=16,
class_mode='categorical')
test_set = train_data.flow_from_directory('test_set',
target_size=(28,28),
batch_size = 16,
class_mode='categorical')
checkpointer = ModelCheckpoint(filepath="best_weight.hdf5",
monitor='val_acc',
verbose=1,
save_best_only=True)
history = classifier.fit_generator(train_set,
steps_per_epoch=210,
epochs=5,
callbacks=[checkpointer],
validation_data=test_set,
validation_steps=90)
classifier.load_weights('best_weights.hdf5')
当我尝试加载最佳权重时,它没有显示此类文件或目录。我应该如何进行更改?非常感谢你们!
答案 0 :(得分:2)
文件名中有错字;您保存在
filepath="best_weight.hdf5"
当您尝试加载'best_weights.hdf5'
时。
从文件名中删除最后一个s
,即:
classifier.load_weights('best_weight.hdf5')