use*_*789 1 machine-learning neural-network deep-learning keras
这种单线程用于保存keras深度学习神经网络模型.
model.save('my_model.h5')
Run Code Online (Sandbox Code Playgroud)
是否model.save()
保存最后时期还是最好的时代的模式?有时,最后一个时期不会改善绩效.
它将模型保存在其当前的精确状态.如果此语句在Model#fit
方法完成之后,则表示最后一个纪元.
对于最佳时期(假设最佳= =最小损失或更高精度),您可以使用ModelCheckpoint:
epochs = 100
# other parameters...
model.fit(x, y,
epochs=epochs,
validation_data=valid,
verbose=2,
callbacks=[
TerminateOnNaN(),
TensorBoard('./logs'),
ModelCheckpoint('best.h5',
save_best_only=True),
...
])
# the model is holding the weights optimized for 100 epochs.
model.load_weights('best.h5') # load weights that generated the min val loss.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
394 次 |
最近记录: |