tf.keras.callbacks是回调函数,在训练过程中可以访问用来做一些决策
- tf.keras.callbacks.EarlyStopping早停函数,当监控目标monitor训练patience轮都不下降时,结束训练
tf.keras.callbacks.EarlyStopping(
monitor='val_loss',
min_delta=0,
patience=0,
verbose=0,
mode='auto',
baseline=None,
restore_best_weights=False
)
- tf.keras.callbacks.LearningRateScheduler学习率衰减函数
自己实现scheduler函数设置学习率衰减形式 3. tf.keras.callbacks.ModelCheckpoint每轮训练结束用来保存模型权重
tf.keras.callbacks.ModelCheckpoint(
filepath,
monitor='val_loss',
verbose=0,
save_best_only=False,
save_weights_only=False,
mode='auto',
save_freq='epoch',
options=None,
initial_value_threshold=None,
**kwargs
)
- tf.keras.callbacks.TensorBoard可视化训练过程
tf.keras.callbacks.TensorBoard(
log_dir='logs',
histogram_freq=0,
write_graph=True,
write_images=False,
write_steps_per_second=False,
update_freq='epoch',
profile_batch=0,
embeddings_freq=0,
embeddings_metadata=None,
**kwargs
)
|