Commit acfcfdd7 authored by dongchy920's avatar dongchy920
Browse files

Update README.md

parent 6c0b8381
......@@ -10,13 +10,9 @@
## 算法原理
通过训练深度卷积神经网络嵌入 (DCNN Embedding) 来进行人脸识别。
ArcFace训练流程:
设类别数(人脸ID数量)为 $n$,DCNN的最后一个FC 层的权重为$W\subset {\mathbb{R}}^{d \times n}$,输入$W$的特征$x_i$的维度为$d$。
1、分别归一化输入特征$x_i \subset {\mathbb{R}}^{b}$和FC层权重$W_j \in {\mathbb{R}}^{1 \times b}$(张量除以欧几里得范数标量),令所得归一化特征$\frac{x_i}{\|x_i\|}$与第$j \in {1,2,...,y_i,...,n}$个类别的FC层权重$\frac{{W_j}^T}{\|W_j\|} \in {\mathbb{R}}^{1\times d}$点乘得到FC层的第$j$个输出$cos \theta_j \in {\mathbb{R}}^{1\times1}$(数量积公式:${W_j}^{T}\cdot x_i=\|W_j\|\|x_i\|cos\theta_j$),表示**将特征$x_i$预测为第$j$类的预测值**
2、设特征$x_i$的真实类别为第$y_j$个类别,单独取出Target权重$\frac{{W_{y_j}}^T}{\|W_{y_i}\|}$计算$\theta_{y_i}=arccos(cos\theta_{y_i})=arccos(\frac{{W_{y_j}}^T}{\|W_{y_i}\|}\cdot\frac{x_i}{\|x_i\|})$可得归一化特征$\frac{x_i}{\|x_i\|}$与归一化**target权重**$\frac{{W_{y_j}}^T}{\|W_{y_i}\|}$之间的夹角—— **Target角度$\theta_{y_i}$**
3、通过把一个自定义的**加性角度边距 (additive angular margin)** $m$加到$\theta_{y_i}$,得到$\theta_{y_i}+m$,用于**调整Target角度**
4、计算经调整的Target角度的余弦,得到仅关于特征$x_i$的真实类别$y_i$的**新Target Logit $cos(\theta_{y_i}+m)$**
5、通过自定义的特征范数$s$重缩放所有Logit(除Target Logit变为$cos(\theta_{y_i}+m)$)外其余原Logit仍为$cos\theta_j$,矩阵运算时需用相当于 0/1 mask的one-hot labels区分)得到新 Logit $s∗cos \theta_j, j\in{1,2,..,y_i,..,n}$。
6、对上述过程得到的**新Logit**按通常方式计算Softmax Loss。
<div align=center>
<img src="yuanli.png"/>
</div>
<div align=center>
<img src="./docs/train.jpg"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment