Home

optimization problem

θ=argminθL(θ)

李宏毅Machine Learning学习笔记3 Gradient Descent

Tip 1: Tuning your Learning rates

李宏毅Machine Learning学习笔记3 Gradient Descent
- 1 small 如果步伐非常小 训练的时间会非常长。
- 2 large 如果步伐非常大 没有办法走到最低点。会在一个范围震荡
- 3 very large 如果步伐太大 loss很快就飞出去了。

visionlize loss 和 参数更新的关系。

李宏毅Machine Learning学习笔记3 Gradient Descent
- 1 learning rate 太小 loss下降非常慢
- 2 lerning rate 太大 loss下降非常快 但是很快就卡住。
- 3 learning rate 特别大 loss很快就飞出去了。

在做梯度下降的时候,最好把这个图画出来。否则你不知道这个梯度下降在哪里坏掉了。

Adaptive Learning Rates

Popular & Simple Idea: Reduce the learning rate by some factor every few epochs.

通常leaning rate 随着参数的update会减小。

  • At the beginning, we are far from the destination, so we use larger learning rate(刚开始的时候,离最低点比较远,所以你的步伐需要大一点。)
  • After several epochs, we are close to the destination, so we reduce the learning rate(经过几次更新之后呢,已经比较靠近目标了,这时候就应该减小learning rate)
  • eg

ηt=η/t+1

Learning rate cannot be one-size-fits-all

Giving different parameters different learning rates

不同的参数有不同的learning rate)

Adagrad

李宏毅Machine Learning学习笔记3 Gradient Descent

w1w0η0δ0g0δ0=(g0)2

w2w1η1δ1g1δ1=12[(g0)2+(g1)2]

w3w2η2δ2g2δ2=13[(g0)2+(g1)2+(g2)2]

wt+1wtηtδtgtδt=1t+1t=0t(gi)2

ηt=ηt+1

wt+1wtηt=0t(gi)2gt

分母 使参数更新更慢 ,分子使参数更新更快。

最好的step 和一次微分成正比,和二次微分成反比。

t=0t(gi)2
“一次微分的平方和开根号代表了二次微分。

Tip2: Stochastic Gradient Descent

如果你现在是在做deep learning 的 case 也就是你的error surface 不是compex 是非常崎岖的。随机取呢是有帮助的。你只算一个example 的loss。

Ln=(y^n(b+wxcpn))2

看一个example,就更新一次参数。参数更新的更快。

Tip3 Feature Scaling

Make different features have the same scaling

不同的feature 有不同的范围。要对feature做缩放。

李宏毅Machine Learning学习笔记3 Gradient Descent

不会向最低点走,而是想着等高线的法线方向去走。

Gradient Descent Theory

在利用梯度下降法(GD)求解损失函数时,参数更新后,Loss不一定下降

Warning of math

Taylor Series (泰勒级数)

h(x)=k=0h(k)(x0)k!(xx0)k

=h(x0)+h(x0)(xx0)+h(x0)2!(xx0)+

when x is close to x0,x-x_0远大于后面的高次项,所以就可以把后面的高次项忽略。

h(x)h(x0)+h(x0)(xx0)

Multivariable Taylor Series

when x is close to x0 y is close to y0

h(x,y)h(x0,y0)+h(x0,y0)x(xx0)+h(x0,y0)y(yy0)

If the red circle is small enough, in the red circle

圆圈足够小。
L(θ)L(a,b)+L(a,b)θ1(θ1a)+L(a,b)θ2(θ2b)

constant(常量)

s=L(a,b)u=L(a,b)θ1v=L(a,b)θ2

L(0θ)L(a,b)+u(θ1a)+v(θ2b)

(θ1a)Δθ1

(θ2b)Δθ2

(Δθ1,Δθ2)and(u,v)

做向量乘积。

李宏毅Machine Learning学习笔记3 Gradient Descent

李宏毅Machine Learning学习笔记3 Gradient Descent

1 我们可以用这个方法找一个最小值,前提是泰勒展开式成立。理论上学习率要无穷小才能保证Loss越来越小。如果你的learning rate 没有设好,导致泰勒展开不成立,所以loss不一定会变小。

2我们只考虑了泰勒级数里的一次式,如果我们把二次式考虑进来,会多很多运算,而这个运算是无法承受的。用这个运算来换更新参数的效率是不划算的。(eg:deep learning)

在做deep learining的时候 考虑二次项的话,你用对二次项的运算来换取learining rate。这个是不划算的,通常是承受不了的。

More Limitation of Gradient Descent

  • stuck at local minima 微分等于0
  • stuck at saddle point 比较平滑的地方 微分约等于0
  • very slow at the plateau 微分等于0

相关文章:

  • 2021-07-23
  • 2021-05-14
  • 2021-08-31
  • 2021-07-26
  • 2021-08-24
  • 2021-10-12
  • 2021-04-05
  • 2021-06-01
猜你喜欢
  • 2021-06-02
  • 2021-04-05
  • 2021-05-17
  • 2021-10-08
  • 2021-12-07
  • 2021-12-12
  • 2021-06-14
相关资源
相似解决方案