📗
deeplearning
  • 机器学习
    • LR & SVM
    • 树模型
    • 评测指标
    • 数据不平衡
  • CV基础
    • 基础模型
    • 初始化
    • 激活函数
    • 注意力机制
    • 损失函数
    • 优化器
    • 可视化
    • 轻量级网络
    • 多任务学习
  • deepfake
    • 数据集
  • 人脸
    • 数据集
    • 人脸对齐
    • 人脸检测
    • 人脸识别
  • 语义分割
    • 语义分割
  • 无监督
    • 无监督
  • 推荐系统
    • 推荐系统模型
    • 推荐系统中的偏差
    • 王喆:深度学习推荐系统
    • 特征处理
    • 重排序
    • 互联网商业化变现
  • 数学
    • bayes最大似然
    • 蒙特卡洛
  • 网站
    • css
    • html
    • js
    • jquery
    • flask
  • 基础工具
    • anaconda
    • docker
    • git
    • linux install
    • vpn
    • latex
  • python
    • numpy
    • matplotlib
    • pandas
    • multi process
    • pytorch
  • 设计模式
    • 设计模式之美
    • 图说设计模式
  • 其他
    • how to ask
    • python style
Powered by GitBook
On this page
  • Contrastive Loss
  • Triplet Loss
  • Center Loss
  • L-Softmax Loss
  • SphereFace
  • CosFace
  • Arcface
  • 人脸损失可视化

Was this helpful?

  1. 人脸

人脸识别

Previous人脸检测Next语义分割

Last updated 3 years ago

Was this helpful?

model
conference
paper
first author
institute
loss fun

DeepFace

CVPR 2014

DeepFace: Closing the Gap to Human-Level Performance in Face Verification

Yaniv Taigman

Facebook AI Lab

sofrmax loss + contrastive loss

DeepID1

CVPR 2014

Deep Learning Face Representation from Predicting 10,000 Classes

Yi Sun

The Chinese University of Hongkong

sofrmax loss + contrastive loss

DeepID2

NIPS 2014

Deep Learning Face Representation by Joint Identification-Verification

Yi Sun

The Chinese University of Hongkong

sofrmax loss + contrastive loss

FaceNet

CVPR 2015

FaceNet: A Unified Embedding for Face Recognition and Clustering

Florian Schroff

google

triplet loss

CenterLoss

ECCV 2016

A Discriminative Feature Learning Approach for Deep Face Recognition

Yandong Wen

Shenzhen key lab of computer Vision and Pattern recognition

center loss

L-sofrmaxLoss

ICML 2016

Large-Margin Softmax Loss for Convolutional Neural Networks

Weiyang Liu & Yandong Wen

Peking Uiversity, South China University of Technology

L-softmax loss

SphereFace

CVPR 2017

SphereFace: Deep Hypersphere Embedding for Face Recognition

Weiyang Liu

Georgia Institute of Technology

A-softmax loss

CosFace

CVPR 2018

CosFace: Large Margin Cosine Loss for Deep Face Recognition

Hao Wang

Tencent AI Lab

large margin cosine loss

ArcFace

CVPR 2019

ArcFace: Additive Angular Margin Loss for Deep Face Recognition

Jiankang Deng & Jia Guo

Imperial College London, InsightFace

additive angular margin loss

人脸识别属于度量学习的范畴,学习到的人脸特征具有以下特点

  • Intra-class Compactness

  • Inter-class Discrepancy

Comparison of open-set and closed-set recognition

Contrastive Loss

Ident⁡(f,t,θid)=−∑i=1n−pilog⁡p^i=−log⁡p^tVerif⁡(fi,fj,yij,θve)={12∥fi−fj∥22 if yij=112max⁡(0,m−∥fi−fj∥2)2 if yij=−1\begin{array}{l} \operatorname{Ident}\left(f, t, \theta_{i d}\right)=-\sum_{i=1}^{n}-p_{i} \log \hat{p}_{i}=-\log \hat{p}_{t} \\ \operatorname{Verif}\left(f_{i}, f_{j}, y_{i j}, \theta_{v e}\right)=\left\{\begin{array}{ll} \frac{1}{2}\left\|f_{i}-f_{j}\right\|_{2}^{2} & \text { if } y_{i j}=1 \\ \frac{1}{2} \max \left(0, m-\left\|f_{i}-f_{j}\right\|_{2}\right)^{2} & \text { if } y_{i j}=-1 \end{array}\right. \end{array}Ident(f,t,θid​)=−∑i=1n​−pi​logp^​i​=−logp^​t​Verif(fi​,fj​,yij​,θve​)={21​∥fi​−fj​∥22​21​max(0,m−∥fi​−fj​∥2​)2​ if yij​=1 if yij​=−1​​

Triplet Loss

Center Loss

L-Softmax Loss

SphereFace

CosFace

Weight Norm and Feature Norm

classification boundary

loss function

其中,NSL是Normalized version of Softmax Loss。

Arcface

人脸损失可视化

loss name
w_norm
x_norm
s
m1
m2
m3

softmax

False

False

1

1

0

0

L-softmax_v1

False

False

1

2

0

0

A-softmax_v1

True

False

1

2

0

0

A-softmax_v2

True

False

1

3

0

0

norm-softmax

True

True

1

1

0

0

CosFace_v1

True

True

4

1

0

0.1

CosFace_v2

True

True

4

1

0

0.2

ArcFace_v1

True

True

4

1

0.1

0

ArcFace_v2

True

True

4

1

0.2

0

ArcFace_v3

True

True

4

1

0.3

0

∑iN[∥f(xia)−f(xip)∥22−∥f(xia)−f(xin)∥22+α]+\sum_{i}^{N}\left[\left\|f\left(x_{i}^{a}\right)-f\left(x_{i}^{p}\right)\right\|_{2}^{2}-\left\|f\left(x_{i}^{a}\right)-f\left(x_{i}^{n}\right)\right\|_{2}^{2}+\alpha\right]_{+}i∑N​[∥f(xia​)−f(xip​)∥22​−∥f(xia​)−f(xin​)∥22​+α]+​
LC=12∑i=1m∥xi−cyi∥22Δcj=∑i=1mδ(yi=j)⋅(cj−xi)1+∑i=1mδ(yi=j)L=LS+λLC=−∑i=1mlog⁡eWyiTxi+byi∑j=1neWjTxi+bj+λ2∑i=1m∥xi−cyi∥22\begin{aligned} \mathcal{L}_{C}=& \frac{1}{2} \sum_{i=1}^{m}\left\|\boldsymbol{x}_{i}-\boldsymbol{c}_{y_{i}}\right\|_{2}^{2} \\ \Delta \boldsymbol{c}_{j}=& \frac{\sum_{i=1}^{m} \delta\left(y_{i}=j\right) \cdot\left(\boldsymbol{c}_{j}-\boldsymbol{x}_{i}\right)}{1+\sum_{i=1}^{m} \delta\left(y_{i}=j\right)} \\ \mathcal{L}=& \mathcal{L}_{S}+\lambda \mathcal{L}_{C} \\ =-& \sum_{i=1}^{m} \log \frac{e^{W_{y_{i}}^{T} \boldsymbol{x}_{i}+b_{y_{i}}}}{\sum_{j=1}^{n} e^{W_{j}^{T} \boldsymbol{x}_{i}+b_{j}}}+\frac{\lambda}{2} \sum_{i=1}^{m}\left\|\boldsymbol{x}_{i}-\boldsymbol{c}_{y_{i}}\right\|_{2}^{2} \end{aligned}LC​=Δcj​=L==−​21​i=1∑m​∥xi​−cyi​​∥22​1+∑i=1m​δ(yi​=j)∑i=1m​δ(yi​=j)⋅(cj​−xi​)​LS​+λLC​i=1∑m​log∑j=1n​eWjT​xi​+bj​eWyi​T​xi​+byi​​​+2λ​i=1∑m​∥xi​−cyi​​∥22​​
∥W1∥∥x∥cos⁡(θ1)>∥W2∥∥x∥cos⁡(θ2)∥W1∥∥x∥cos⁡(θ1)≥∥W1∥∥x∥cos⁡(mθ1)>∥W2∥∥x∥cos⁡(θ2)Li=−log⁡(e∥Wyi∥∥xi∥ψ(θyi)e∥Wyi∥∥xi∥ψ(θyi)+∑j≠yie∥Wj∥∥xi∥cos⁡(θj))ψ(θ)={cos⁡(mθ),0≤θ≤πmD(θ),πm<θ≤πψ(θ)=(−1)kcos⁡(mθ)−2k,θ∈[kπm,(k+1)πm]\begin{array}{l} \left\|\boldsymbol{W}_{1}\right\|\|\boldsymbol{x}\| \cos \left(\theta_{1}\right)>\left\|\boldsymbol{W}_{2}\right\|\|\boldsymbol{x}\| \cos \left(\theta_{2}\right) \\ \\ \begin{aligned} \left\|\boldsymbol{W}_{1}\right\|\|\boldsymbol{x}\| \cos \left(\theta_{1}\right) & \geq\left\|\boldsymbol{W}_{1}\right\|\|\boldsymbol{x}\| \cos \left(m \theta_{1}\right) \\ &>\left\|\boldsymbol{W}_{2}\right\|\|\boldsymbol{x}\| \cos \left(\theta_{2}\right) \end{aligned} \\ L_{i}=-\log \left(\frac{e^{\left\|\boldsymbol{W}_{y_{i}}\right\|\left\|\boldsymbol{x}_{i}\right\| \psi\left(\theta_{y_{i}}\right)}}{e^{\left\|\boldsymbol{W}_{y_{i}}\right\|\left\|\boldsymbol{x}_{i}\right\| \psi\left(\theta_{y_{i}}\right)}+\sum_{j \neq y_{i}} e^{\left\|\boldsymbol{W}_{j}\right\|\left\|\boldsymbol{x}_{i}\right\| \cos \left(\theta_{j}\right)}}\right) \end{array} \\ \psi(\theta)=\left\{\begin{array}{l} \cos (m \theta), \quad 0 \leq \theta \leq \frac{\pi}{m} \\ \mathcal{D}(\theta), \quad \frac{\pi}{m}<\theta \leq \pi \end{array}\right. \\ \psi(\theta)=(-1)^{k} \cos (m \theta)-2 k, \quad \theta \in\left[\frac{k \pi}{m}, \frac{(k+1) \pi}{m}\right] \\∥W1​∥∥x∥cos(θ1​)>∥W2​∥∥x∥cos(θ2​)∥W1​∥∥x∥cos(θ1​)​≥∥W1​∥∥x∥cos(mθ1​)>∥W2​∥∥x∥cos(θ2​)​Li​=−log(e∥Wyi​​∥∥xi​∥ψ(θyi​​)+∑j=yi​​e∥Wj​∥∥xi​∥cos(θj​)e∥Wyi​​∥∥xi​∥ψ(θyi​​)​)​ψ(θ)={cos(mθ),0≤θ≤mπ​D(θ),mπ​<θ≤π​ψ(θ)=(−1)kcos(mθ)−2k,θ∈[mkπ​,m(k+1)π​]
 Weight Norm and zero bias ∥Wi∥=1,bi=0 Classification boundary cos⁡(mθ1)=cos⁡(θ2)Lang=1N∑i−log⁡(e∥xi∥ψ(θyi,i)e∥xi∥ψ(θyi,i)+∑j≠yie∥xi∥cos⁡(θj,i))\begin{aligned} &\text { Weight Norm and zero bias } \quad\left\|\boldsymbol{W}_{i}\right\|=1, b_{i}=0\\ &\text { Classification boundary } \cos \left(m \theta_{1}\right)=\cos \left(\theta_{2}\right)\\ &L_{\mathrm{ang}}=\frac{1}{N} \sum_{i}-\log \left(\frac{e^{\left\|\boldsymbol{x}_{i}\right\| \psi\left(\theta_{y_{i}, i}\right)}}{e^{\left\|\boldsymbol{x}_{i}\right\| \psi\left(\theta_{y_{i}, i}\right)}+\sum_{j \neq y_{i}} e^{\left\|\boldsymbol{x}_{i}\right\| \cos \left(\theta_{j, i}\right)}}\right) \end{aligned}​ Weight Norm and zero bias ∥Wi​∥=1,bi​=0 Classification boundary cos(mθ1​)=cos(θ2​)Lang​=N1​i∑​−log​e∥xi​∥ψ(θyi​,i​)+∑j=yi​​e∥xi​∥cos(θj,i​)e∥xi​∥ψ(θyi​,i​)​​​
W=W∗∥W∗∥x=x∗∥x∗∥cos⁡(θj,i)=WjTxi\begin{aligned} W &=\frac{W^{*}}{\left\|W^{*}\right\|} \\ x &=\frac{x^{*}}{\left\|x^{*}\right\|} \\ \cos \left(\theta_{j}, i\right) &=W_{j}^{T} x_{i} \end{aligned}Wxcos(θj​,i)​=∥W∗∥W∗​=∥x∗∥x∗​=WjT​xi​​
cos⁡(θ1)−m>cos⁡(θ2) and cos⁡(θ2)−m>cos⁡(θ1)\cos \left(\theta_{1}\right)-m>\cos \left(\theta_{2}\right) \text { and } \cos \left(\theta_{2}\right)-m>\cos \left(\theta_{1}\right)cos(θ1​)−m>cos(θ2​) and cos(θ2​)−m>cos(θ1​)
Llmc=1N∑i−log⁡es(cos⁡(θyi,i)−m)es(cos⁡(θyi,i)−m)+∑j≠yiescos⁡(θj,i)L_{l m c}=\frac{1}{N} \sum_{i}-\log \frac{e^{s\left(\cos \left(\theta_{y_{i}, i}\right)-m\right)}}{e^{s\left(\cos \left(\theta_{y_{i}, i}\right)-m\right)}+\sum_{j \neq y_{i}} e^{s \cos \left(\theta_{j, i}\right)}}Llmc​=N1​i∑​−loges(cos(θyi​,i​)−m)+∑j=yi​​escos(θj,i​)es(cos(θyi​,i​)−m)​
cos⁡(θ1−m)>cos⁡(θ2)L3=−1N∑i=1Nlog⁡es(cos⁡(θyi+m))es(cos⁡(θyi+m))+∑j=1,j≠yinescos⁡θj.L4=−1N∑i=1Nlog⁡es(cos⁡(m1θyi+m2)−m3)es(cos⁡(m1θji+m2)−m3)+∑j=1,j≠yinescos⁡θj.\begin{array}{l} \cos \left(\theta_{1}-m\right)>\cos \left(\theta_{2}\right) \\ L_{3}=-\frac{1}{N} \sum_{i=1}^{N} \log \frac{e^{s\left(\cos \left(\theta_{y_{i}}+m\right)\right)}}{e^{s\left(\cos \left(\theta_{y_{i}}+m\right)\right)}+\sum_{j=1, j \neq y_{i}}^{n} e^{s \cos \theta_{j}}} . \\ L_{4}=-\frac{1}{N} \sum_{i=1}^{N} \log \frac{e^{s\left(\cos \left(m_{1} \theta_{y_{i}}+m_{2}\right)-m_{3}\right)}}{\left.e^{s\left(\cos \left(m_{1} \theta_{j_{i}}+m_{2}\right)-m_{3}\right.}\right)+\sum_{j=1, j \neq y_{i}}^{n} e^{s \cos \theta_{j}}} . \end{array}cos(θ1​−m)>cos(θ2​)L3​=−N1​∑i=1N​loges(cos(θyi​​+m))+∑j=1,j=yi​n​escosθj​es(cos(θyi​​+m))​.L4​=−N1​∑i=1N​loges(cos(m1​θji​​+m2​)−m3​)+∑j=1,j=yi​n​escosθj​es(cos(m1​θyi​​+m2​)−m3​)​.​

采用通用的人脸损失公式,采用不同的参数如下,在minist上的可视化效果见

Visualization of Face Loss