ReduceLROnPlateau

本文介绍tf.keras.callbacks.ReduceLROnPlateau的使用方法,该回调函数可在验证集损失不再改善时自动减少学习率,有助于解决训练过程中的学习率调整难题。文章详细解释了各个参数的意义及配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Last updated: 2022-09-01, 17:25


简介

tf.keras.callbacks.ReduceLROnPlateau(
    monitor='val_loss',
    factor=0.1,
    patience=10,
    verbose=0,
    mode='auto',
    min_delta=0.0001,
    cooldown=0,
    min_lr=0,
    **kwargs
)

当 metric 停止改善时,降低学习率(learning rate, LR)。

在学习停滞时,将学习率降低 2-10 倍往往对训练有利。该 callback 监视某个指标,如果在 patience 个 epochs 该指标都没有改善,就降低 LR。

参数

monitor

要监视的量值。

factor

学习率降低的因子,new_lr = lr * factor

patience

如果在 patience 个 epochs 后没有改善,就降低学习率。

verbose

int. 0: quiet, 1: update messages.

mode

one of {‘auto’, ‘min’, ‘max’}:

  • In ‘min’ mode, the learning rate will be reduced when the quantity monitored has stopped decreasing;
  • in ‘max’ mode it will be reduced when the quantity monitored has stopped increasing;
  • in ‘auto’ mode, the direction is automatically inferred from the name of the monitored quantity.

min_delta

threshold for measuring the new optimum, to only focus on significant changes.

cooldown

number of epochs to wait before resuming normal operation after lr has been reduced.

min_lr

学习率最小值。

示例

reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.2,
                              patience=5, min_lr=0.001)
model.fit(X_train, Y_train, callbacks=[reduce_lr])

参考

  • https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/ReduceLROnPlateau
  • https://keras.io/api/callbacks/reduce_lr_on_plateau/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值