---
# System prepended metadata

title: ArcFace (CVPR2019)
tags: [Human Face]

---

---
tags: Human Face
---
# ArcFace (CVPR2019)

## 起源（？

### softmax loss 缺點

$$
L = -\frac{1}{N}\sum^N_{i=1}log\frac{e^{W^{T}_{y_{i}}x_i+b_{y_i}}}{\Sigma^n_{j=1}e^{W^{T}_{j}x_i+b_{j}}}
$$

1. 沒有 Margin 的概念
2. $W$ 跟著類別線性成長
 
### Triplet loss 缺點
$$
L = \sum^N_i\big[\|f(x^\alpha_i)-f(x^p_i)\|^2_2- \|f(x^\alpha_i)-f(x^n_i)\|^2_2\big]
$$

1. image pair combinatorial explosion
2. semi-hard sample mining


> 圖像之間的比較，轉換到圖像與類別(class center)之間的比較（類別的數目是遠小於圖片的數目）

:::info
重點就在找出能代表該類別的高維度點ＲＲＲＲＲＲＲ
:::

## pipeline
![](https://i.imgur.com/4Z9edb2.png)
### Step1: $X$ and $W$ Normalization
$$
L_1 = -\frac{1}{N}\sum^N_{i=1}log\frac{e^{W^{T}_{y_{i}}x_i+b_{y_i}}}{\Sigma^n_{j=1}e^{W^{T}_{j}x_i+b_{j}}}
$$

$W^{T}_{y_{i}}x_i=\|W_j\|\|x_i\|cos\theta_j=cos\theta_j$

$$
L_2 = -\frac{1}{N}\sum^N_{i=1}log\frac{e^{s \ cos\theta_{y_i}}}{e^{s\ cos \theta_{y_i}} + \Sigma^n_{j=1,j\neq y_i}e^{s\ cos \theta_{y_i}} }
$$

> $W$ 可以看作代表某一類的 center

### Step2: Additivez Angular Margin
$$
L_3 = -\frac{1}{N}\sum^N_{i=1}log\frac{e^{s \ cos(\theta_{y_i}+m)}}{e^{s\ cos (\theta_{y_i}+m)} + \Sigma^n_{j=1,j\neq y_i}e^{s\ cos \theta_{y_i}} }
$$


### 組合技
$$
L_4 = -\frac{1}{N}\sum^N_{i=1}log\frac{e^{s \ (cos(m_1\theta_{y_i}+m_2) - m_3)}}{e^{s\ (cos(m_1\theta_{y_i}+m_2) - m_3)} + \Sigma^n_{j=1,j\neq y_i}e^{s\ cos \theta_{y_i}} }
$$

- SphereFace：$m_1$
- CosFace：$m_3$


## 優點
1. 代碼簡單
![](https://i.imgur.com/XTnQ5il.png)
3. 易解釋
直接去對應角度空間
![](https://i.imgur.com/kjkySMz.png)
5. 高效，訓練速度快，利用 $W$ 的分組進行大規模的訓練
![](https://i.imgur.com/vDC51zH.png)

![](https://i.imgur.com/6Ml5DCy.png =305x)![](https://i.imgur.com/XkcspsU.png =305x)


> $W$ is large but we can easily split it.
> Parallel acceleration on both $x$ and $W$.
 

## 問題
1. 類別增加角度增加？ 
    - 這個是高維度空間，多增加一類人是不會擠壓他其他人臉的角度的
2. $m$ 怎摸去做調整？
    - 偶不豬到 
