Motivation
- 极大化类间differences ,极小化类内variations !!!
Novelty
- L2-normalizing both features and weight vectors to remove radial variation.
- Cosine Loss
Details
-
Margin
- Softmax loss : ||w_i||cos(theta_i) = ||w_j||cos(theta_j), 分类面受||w||和cos(theta)的影响可能存在overlap,因此margin<=0.
- Normalized-SM : cos(theta_i) = cos(theta_j), 消除||w||对分类面的影响,margin = 0.
- Angular-SM : cos(mθ1) ≥ cos(θ2) for C1, cos(mθ2) ≥ cos(θ1) for C2, margin >= 0, 并随着theta同向单调变化.
- LMCL-SM :cos(θ1) ≥ cos(θ2) + m for C1, cos(θ2) ≥ cos(θ1) + m for C2, margin = sqrt(2)m.
备注:前4幅小图是从loss-boundary的视角呈现的;后2幅图是从feature-boundary的视角呈现的.
- Normalization on Features
,
- 对于easy样本,cos(theta_yn_n) >> cos(theta_i_n)[i != yn],在softmax中显然exp(cos(theta_yn_n))占据主导地位,为了使得样本的loss减小,模型会趋向于学习||x_n||_2大一些的embeddig_feature;
- 对于hard样本,cos(theta_yn_n) 与 cos(theta_i_n)[i != yn]起鼓相当,甚至还小于max(cos(theta_i_n)[i != yn]),这样在softmax中就处于劣势地位,为了使得样本的loss减小,模型会趋向于学习||x_n||_2小一些的embeddig_feature;
- 综合(1)、(2)的分析,如果我们强制将embeddig_feature的L2-norm设置为相同的scale,那么模型在训练过程中为了减低样本的loss,就只能不断push相应的类向量[w_yn]和样本x_n的夹角变小,从而增加了embeddig_feature的区分能力!
- 从模型优化的角度来看,在初始化模型时将cos(theta_i)[i=1, 2, ..., K]置为起鼓相当的值,为了减小样本的loss,模型会趋向于通过降低||x_n||_2而不是减小相应的类向量[w_yn]和样本x_n的夹角的方式来优化,这会导致特征的区分能力减弱!
- s = ||x||_L2,取值过小可能导致模型收敛过慢、甚至不不收敛的情况;s取值过大,会增加模型学习难度、过早陷入局部最优解.
Experiment
- Visualize
- Normalization
- Benchmark
Reference
[1]. CosFace: Large Margin Cosine Loss for Deep Face Recognition