DQN 中的梯度 clip

首先看这个 https://stackoverflow.com/questions/36462962/loss-clipping-in-tensor-flow-on-deepminds-dqn

DQN 文章中提到的 clip 并不是 梯度 clip。

首先看一下 tensorflow 1 中的 huber_loss,令 d = 1。

  0.5 * x^2                  if |x| <= d
  0.5 * d^2 + d * (|x| - d)  if |x| > d

其导数为

f'(x) = x    if x in [-1, 1]
f'(x) = +1    if x > +1
f'(x) = -1    if x < -1

l o s s = f ( y i − y i ^ ) l o s s ′ = f ′ ( y i − y i ^ ) ⋅ y i ′ = f ′ ( z ) ⋅ y i ′ loss = f(y_i-\hat{y_i}) \\ loss'=f'(y_i-\hat{y_i})\cdot y_i'=f'(z)\cdot y_i' loss=f(yiyi^)loss=f(yiyi^)yi=f(z)yi

DQN 文中提到

We also found it helpful to clip the error term from the update to be between −1 and 1. Because the absolute value loss function |x| has a derivative of −1 for all negative values of x and a derivative of 1 for all positive values of x, clipping the squared error to be between −1 and 1 corresponds to using an absolute value loss function for errors outside of the (−1,1) interval. This form of error clipping further improved the stability of the algorithm.

但这个指的是 f ′ ( z ) f'(z) f(z) 处于 -1 和 1 之间。而梯度 clip 则是把 f ′ ( z ) ⋅ y i ′ f'(z)\cdot y'_i f(z)yi 整体处于 -1 到 1 之间。

Use the Huber loss function, the Mnih et al 2013 paper called this error clipping.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值