我是Keras的新手。我想保存具有最佳权重的模型,例如:
model1.compile(loss="mean_squared_error", optimizer="RMSprop")
model1.summary()
mcp_save = ModelCheckpoint('best_model.h5', save_best_only=True, monitor='val_accuracy', mode='auto', verbose=2)
callbacks_list = [mcp_save]
epochs = 5000
batch_size = 50
# fit the model
history = model1.fit(x_train, y_train,
batch_size=batch_size,
epochs=epochs,
callbacks=callbacks_list,
validation_data=(x_test, y_test),
verbose=2)
我在Pycharm 2019 Community Edition上没有遇到警告或错误消息。但是在训练过程完成后,我无法在项目文件文件夹或计算机上的其他位置看到'best_model.h5'?你能给我建议吗?我有什么错?
您的代码对我来说不错。我经常使用此回调。我只能建议您使用完整路径指定保存模型的位置,而不是相对路径。