优化算法进阶;word2vec;词嵌入进阶

目录
优化算法进阶
An ill-conditioned Problem
Maximum Learning Rate
Supp: Preconditioning
Solution to ill-condition
Momentum Algorithm
Exponential Moving Average
Supp
由指数加权移动平均理解动量法
Pytorch Class
AdaGrad
Algorithm
Feature
Pytorch Class
RMSProp
Algorithm
Pytorch Class
AdaDelta
Algorithm
Implement
Pytorch Class
Adam
Algorithm
Implement
Pytorch Class
word2vec
二次采样
Skip-Gram 模型的前向计算
负采样近似
损失函数
词嵌入进阶
GloVe 全局向量的词嵌入
GloVe 模型
载入预训练的 GloVe 向量
求类比词
优化算法进阶
在每次迭代中,梯度下降根据自变量当前位置,沿着当前位置的梯度更新自变量。然而,如果自变量的迭代方向仅仅取决于自变量当前位置,这可能会带来一些问题。对于noisy gradient,我们需要谨慎的选取学习率和batch size, 来控制梯度方差和收敛的结果。

gt=∂w1∣Bt∣∑i∈Btf(xi,wt−1)=1∣Bt∣∑i∈Btgi,t−1. \mathbf{g}t = \partial{\mathbf{w}} \frac{1}{|\mathcal{B}t|} \sum{i \in \mathcal{B}t} f(\mathbf{x}{i}, \mathbf{w}{t-1}) = \frac{1}{|\mathcal{B}t|} \sum{i \in \mathcal{B}t} \mathbf{g}{i, t-1}.
An ill-conditioned Problem
Condition Number of Hessian Matrix:
condH=λmaxλmin cond
{H} = \frac{\lambda_{max}}{\lambda_{min}}
cond
=20→ill-conditioned

一般来说condition number比较大时即认定该问题为ill-conditioner problem.可参考神经网络优化中的病态问题

Maximum Learning Rate
For f(x) f(x)f(x), according to convex optimizaiton conclusions, we need step size η≤1L \eta \leq \frac{1}{L}η≤


且不满足 η≤1L \eta \leq \frac{1}{L}η≤
L
1

时,函数将在区间谷壁对碰折线递减迭代,但依旧能够保证最终收敛到最小点,而当某一维坐标上学习率不满足在该坐标上η≤2L \eta \leq \frac{2}{L}η≤
L
2

时,函数将不能递减迭代,也不能收敛到该维度上的最小点处。

Supp: Preconditioning
在二阶优化中,我们使用Hessian matrix的逆矩阵(或者pseudo inverse)来左乘梯度向量 i.e.Δx=H−1g i.e. \Delta_{x} = H^{-1}\mathbf{g}i.e.Δ
x

=H
−1
g,这样的做法称为precondition,相当于将 H HH 映射为一个单位矩阵,拥有分布均匀的Spectrum,也即我们去优化的等价标函数的Hessian matrix为良好的identity matrix,同一个学习率在各个坐标维度上递减迭代减少量接近,就不会出现在某一维度上学习率过高而另一维度上则学习率过低的情况。

Solution to ill-condition
Preconditioning gradient vector: applied in Adam, RMSProp, AdaGrad, Adelta, KFC, Natural gradient and other secord-order optimization algorithms.
Averaging history gradient: like momentum, which allows larger learning rates to accelerate convergence; applied in Adam, RMSProp, SGD momentum.
Momentum Algorithm
动量法的提出是为了解决梯度下降的上述问题。设时间步 t tt 的自变量为 xt \boldsymbol{x}_tx
t

,学习率为 ηt \eta_tη
t


在时间步 t=0 t=0t=0,动量法创建速度变量 m0 \boldsymbol{m}_0m
0

,并将其元素初始化成 0。在时

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值