-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCosFace.txt
2028 lines (1949 loc) · 51.4 KB
/
CosFace.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CosFace: Large Margin Cosine Loss for Deep Face Recognition
Hao Wang
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Yitong Wang
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Zheng Zhou
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Xing Ji
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Dihong Gong
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Jingchao Zhou
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Zhifeng Li
Corresponding authors Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
and Wei Liu†
Tencent AI Lab
{hawelwang,yitongwang,encorezhou,denisji,sagazhou,michaelzfli}@tencent.com [email protected] [email protected]
Abstract
Face recognition has made extraordinary progress owing to the advancement of deep convolutional neural networks (CNNs). The central task of face recognition, including face verification and identification, involves face feature discrimination. However, the traditional softmax loss of deep CNNs usually lacks the power of discrimination. To address this problem, recently several loss functions such as center loss, large margin softmax loss, and angular softmax loss have been proposed. All these improved losses share the same idea: maximizing inter-class variance and minimizing intra-class variance. In this paper, we propose a novel loss function, namely large margin cosine loss (LMCL), to realize this idea from a different perspective. More specifically, we reformulate the softmax loss as a cosine loss by
𝐿
2
normalizing both features and weight vectors to remove radial variations, based on which a cosine margin term is introduced to further maximize the decision margin in the angular space. As a result, minimum intra-class variance and maximum inter-class variance are achieved by virtue of normalization and cosine decision margin maximization. We refer to our model trained with LMCL as CosFace. Extensive experimental evaluations are conducted on the most popular public-domain face recognition datasets such as MegaFace Challenge, Youtube Faces (YTF) and Labeled Face in the Wild (LFW). We achieve the state-of-the-art performance on these benchmarks, which confirms the effectiveness of our proposed approach.
Refer to caption
Figure 1:An overview of the proposed CosFace framework. In the training phase, the discriminative face features are learned with a large margin between different classes. In the testing phase, the testing data is fed into CosFace to extract face features which are later used to compute the cosine similarity score to perform face verification and identification.
1Introduction
Recently progress on the development of deep convolutional neural networks (CNNs) [15, 18, 12, 9, 44] has significantly advanced the state-of-the-art performance on a wide variety of computer vision tasks, which makes deep CNN a dominant machine learning approach for computer vision. Face recognition, as one of the most common computer vision tasks, has been extensively studied for decades [37, 45, 22, 19, 20, 40, 2]. Early studies build shallow models with low-level face features, while modern face recognition techniques are greatly advanced driven by deep CNNs. Face recognition usually includes two sub-tasks: face verification and face identification. Both of these two tasks involve three stages: face detection, feature extraction, and classification. A deep CNN is able to extract clean high-level features, making itself possible to achieve superior performance with a relatively simple classification architecture: usually, a multilayer perceptron networks followed by a softmax loss [35, 32]. However, recent studies [42, 24, 23] found that the traditional softmax loss is insufficient to acquire the discriminating power for classification.
To encourage better discriminating performance, many research studies have been carried out [42, 5, 7, 10, 39, 23]. All these studies share the same idea for maximum discrimination capability: maximizing inter-class variance and minimizing intra-class variance. For example, [42, 5, 7, 10, 39] propose to adopt multi-loss learning in order to increase the feature discriminating power. While these methods improve classification performance over the traditional softmax loss, they usually come with some extra limitations. For [42], it only explicitly minimizes the intra-class variance while ignoring the inter-class variances, which may result in suboptimal solutions. [5, 7, 10, 39] require thoroughly scheming the mining of pair or triplet samples, which is an extremely time-consuming procedure. Very recently, [23] proposed to address this problem from a different perspective. More specifically, [23] (A-softmax) projects the original Euclidean space of features to an angular space, and introduces an angular margin for larger inter-class variance.
Compared to the Euclidean margin suggested by [42, 5, 10], the angular margin is preferred because the cosine of the angle has intrinsic consistency with softmax. The formulation of cosine matches the similarity measurement that is frequently applied to face recognition. From this perspective, it is more reasonable to directly introduce cosine margin between different classes to improve the cosine-related discriminative information.
In this paper, we reformulate the softmax loss as a cosine loss by
𝐿
2
normalizing both features and weight vectors to remove radial variations, based on which a cosine margin term
𝑚
is introduced to further maximize the decision margin in the angular space. Specifically, we propose a novel algorithm, dubbed Large Margin Cosine Loss (LMCL), which takes the normalized features as input to learn highly discriminative features by maximizing the inter-class cosine margin. Formally, we define a hyper-parameter
𝑚
such that the decision boundary is given by
𝑐
𝑜
𝑠
(
𝜃
1
)
−
𝑚
=
𝑐
𝑜
𝑠
(
𝜃
2
)
, where
𝜃
𝑖
is the angle between the feature and weight of class
𝑖
.
For comparison, the decision boundary of the A-Softmax is defined over the angular space by
cos
(
𝑚
𝜃
1
)
=
cos
(
𝜃
2
)
, which has a difficulty in optimization due to the non-monotonicity of the cosine function. To overcome such a difficulty, one has to employ an extra trick with an ad-hoc piecewise function for A-Softmax. More importantly, the decision margin of A-softmax depends on
𝜃
, which leads to different margins for different classes. As a result, in the decision space, some inter-class features have a larger margin while others have a smaller margin, which reduces the discriminating power. Unlike A-Softmax, our approach defines the decision margin in the cosine space, thus avoiding the aforementioned shortcomings.
Based on the LMCL, we build a sophisticated deep model called CosFace, as shown in Figure 1. In the training phase, LMCL guides the ConvNet to learn features with a large cosine margin. In the testing phase, the face features are extracted from the ConvNet to perform either face verification or face identification. We summarize the contributions of this work as follows:
(1) We embrace the idea of maximizing inter-class variance and minimizing intra-class variance and propose a novel loss function, called LMCL, to learn highly discriminative deep features for face recognition.
(2) We provide reasonable theoretical analysis based on the hyperspherical feature distribution encouraged by LMCL.
(3) The proposed approach advances the state-of-the-art performance over most of the benchmarks on popular face databases including LFW[13], YTF[43] and Megaface [17, 25].
2Related Work
Deep Face Recognition. Recently, face recognition has achieved significant progress thanks to the great success of deep CNN models [18, 15, 34, 9]. In DeepFace [35] and DeepID [32], face recognition is treated as a multi-class classification problem and deep CNN models are first introduced to learn features on large multi-identities datasets. DeepID2 [30] employs identification and verification signals to achieve better feature embedding. Recent works DeepID2+ [33] and DeepID3 [31] further explore the advanced network structures to boost recognition performance. FaceNet [29] uses triplet loss to learn an Euclidean space embedding and a deep CNN is then trained on nearly 200 million face images, leading to the state-of-the-art performance. Other approaches [41, 11] also prove the effectiveness of deep CNNs on face recognition.
Loss Functions. Loss function plays an important role in deep feature learning. Contrastive loss [5, 7] and triplet loss [10, 39] are usually used to increase the Euclidean margin for better feature embedding. Wen et al. [42] proposed a center loss to learn centers for deep features of each identity and used the centers to reduce intra-class variance. Liu et al. [24] proposed a large margin softmax (L-Softmax) by adding angular constraints to each identity to improve feature discrimination. Angular softmax (A-Softmax) [23] improves L-Softmax by normalizing the weights, which achieves better performance on a series of open-set face recognition benchmarks [13, 43, 17]. Other loss functions [47, 6, 4, 3] based on contrastive loss or center loss also demonstrate the performance on enhancing discrimination.
Normalization Approaches. Normalization has been studied in recent deep face recognition studies. [38] normalizes the weights which replace the inner product with cosine similarity within the softmax loss. [28] applies the
𝐿
2
constraint on features to embed faces in the normalized space. Note that normalization on feature vectors or weight vectors achieves much lower intra-class angular variability by concentrating more on the angle during training. Hence the angles between identities can be well optimized. The von Mises-Fisher (vMF) based methods [48, 8] and A-Softmax [23] also adopt normalization in feature learning.
3Proposed Approach
In this section, we firstly introduce the proposed LMCL in detail (Sec. 3.1). And a comparison with other loss functions is given to show the superiority of the LMCL (Sec. 3.2). The feature normalization technique adopted by the LMCL is further described to clarify its effectiveness (Sec. 3.3). Lastly, we present a theoretical analysis for the proposed LMCL (Sec. 3.4).
3.1Large Margin Cosine Loss
We start by rethinking the softmax loss from a cosine perspective. The softmax loss separates features from different classes by maximizing the posterior probability of the ground-truth class. Given an input feature vector
𝑥
𝑖
with its corresponding label
𝑦
𝑖
, the softmax loss can be formulated as:
𝐿
𝑠
=
1
𝑁
∑
𝑖
=
1
𝑁
−
log
𝑝
𝑖
=
1
𝑁
∑
𝑖
=
1
𝑁
−
log
𝑒
𝑓
𝑦
𝑖
∑
𝑗
=
1
𝐶
𝑒
𝑓
𝑗
,
(1)
where
𝑝
𝑖
denotes the posterior probability of
𝑥
𝑖
being correctly classified.
𝑁
is the number of training samples and
𝐶
is the number of classes.
𝑓
𝑗
is usually denoted as activation of a fully-connected layer with weight vector
𝑊
𝑗
and bias
𝐵
𝑗
. We fix the bias
𝐵
𝑗
=
0
for simplicity, and as a result
𝑓
𝑗
is given by:
𝑓
𝑗
=
𝑊
𝑗
𝑇
𝑥
=
‖
𝑊
𝑗
‖
‖
𝑥
‖
cos
𝜃
𝑗
,
(2)
where
𝜃
𝑗
is the angle between
𝑊
𝑗
and
𝑥
. This formula suggests that both norm and angle of vectors contribute to the posterior probability.
To develop effective feature learning, the norm of
𝑊
should be necessarily invariable. To this end, We fix
‖
𝑊
𝑗
‖
=
1
by
𝐿
2
normalization. In the testing stage, the face recognition score of a testing face pair is usually calculated according to cosine similarity between the two feature vectors. This suggests that the norm of feature vector
𝑥
is not contributing to the scoring function. Thus, in the training stage, we fix
‖
𝑥
‖
=
𝑠
. Consequently, the posterior probability merely relies on cosine of angle. The modified loss can be formulated as
𝐿
𝑛
𝑠
=
1
𝑁
∑
𝑖
−
log
𝑒
𝑠
cos
(
𝜃
𝑦
𝑖
,
𝑖
)
∑
𝑗
𝑒
𝑠
cos
(
𝜃
𝑗
,
𝑖
)
.
(3)
Because we remove variations in radial directions by fixing
‖
𝑥
‖
=
𝑠
, the resulting model learns features that are separable in the angular space. We refer to this loss as the Normalized version of Softmax Loss (NSL) in this paper.
However, features learned by the NSL are not sufficiently discriminative because the NSL only emphasizes correct classification. To address this issue, we introduce the cosine margin to the classification boundary, which is naturally incorporated into the cosine formulation of Softmax.
Considering a scenario of binary-classes for example, let
𝜃
𝑖
denote the angle between the learned feature vector and the weight vector of Class
𝐶
𝑖
(
𝑖
=
1
,
2
)
. The NSL forces
cos
(
𝜃
1
)
>
cos
(
𝜃
2
)
for
𝐶
1
, and similarly for
𝐶
2
, so that features from different classes are correctly classified. To develop a large margin classifier, we further require
cos
(
𝜃
1
)
−
𝑚
>
cos
(
𝜃
2
)
and
cos
(
𝜃
2
)
−
𝑚
>
cos
(
𝜃
1
)
, where
𝑚
≥
0
is a fixed parameter introduced to control the magnitude of the cosine margin. Since
cos
(
𝜃
𝑖
)
−
𝑚
is lower than
cos
(
𝜃
𝑖
)
, the constraint is more stringent for classification. The above analysis can be well generalized to the scenario of multi-classes. Therefore, the altered loss reinforces the discrimination of learned features by encouraging an extra margin in the cosine space.
Refer to caption
Figure 2:The comparison of decision margins for different loss functions the binary-classes scenarios. Dashed line represents decision boundary, and gray areas are decision margins.
Formally, we define the Large Margin Cosine Loss (LMCL) as:
𝐿
𝑙
𝑚
𝑐
=
1
𝑁
∑
𝑖
−
log
𝑒
𝑠
(
cos
(
𝜃
𝑦
𝑖
,
𝑖
)
−
𝑚
)
𝑒
𝑠
(
cos
(
𝜃
𝑦
𝑖
,
𝑖
)
−
𝑚
)
+
∑
𝑗
≠
𝑦
𝑖
𝑒
𝑠
cos
(
𝜃
𝑗
,
𝑖
)
,
(4)
subject to
𝑊
=
𝑊
∗
‖
𝑊
∗
‖
,
𝑥
=
𝑥
∗
‖
𝑥
∗
‖
,
𝑐
𝑜
𝑠
(
𝜃
𝑗
,
𝑖
)
=
𝑊
𝑗
𝑇
𝑥
𝑖
,
(5)
where
𝑁
is the numer of training samples,
𝑥
𝑖
is the
𝑖
-th feature vector corresponding to the ground-truth class of
𝑦
𝑖
, the
𝑊
𝑗
is the weight vector of the
𝑗
-th class, and
𝜃
𝑗
is the angle between
𝑊
𝑗
and
𝑥
𝑖
.
3.2Comparison on Different Loss Functions
In this subsection, we compare the decision margin of our method (LMCL) to: Softmax, NSL, and A-Softmax, as illustrated in Figure 2. For simplicity of analysis, we consider the binary-classes scenarios with classes
𝐶
1
and
𝐶
2
. Let
𝑊
1
and
𝑊
2
denote weight vectors for
𝐶
1
and
𝐶
2
, respectively.
Softmax loss defines a decision boundary by:
‖
𝑊
1
‖
cos
(
𝜃
1
)
=
‖
𝑊
2
‖
cos
(
𝜃
2
)
.
Thus, its boundary depends on both magnitudes of weight vectors and cosine of angles, which results in an overlapping decision area (margin
<
0) in the cosine space. This is illustrated in the first subplot of Figure 2. As noted before, in the testing stage it is a common strategy to only consider cosine similarity between testing feature vectors of faces. Consequently, the trained classifier with the Softmax loss is unable to perfectly classify testing samples in the cosine space.
NSL normalizes weight vectors
𝑊
1
and
𝑊
2
such that they have constant magnitude 1, which results in a decision boundary given by:
cos
(
𝜃
1
)
=
cos
(
𝜃
2
)
.
The decision boundary of NSL is illustrated in the second subplot of Figure 2. We can see that by removing radial variations, the NSL is able to perfectly classify testing samples in the cosine space, with margin = 0. However, it is not quite robust to noise because there is no decision margin: any small perturbation around the decision boundary can change the decision.
A-Softmax improves the softmax loss by introducing an extra margin, such that its decision boundary is given by:
𝐶
1
:
cos
(
𝑚
𝜃
1
)
≥
cos
(
𝜃
2
)
,
𝐶
2
:
cos
(
𝑚
𝜃
2
)
≥
cos
(
𝜃
1
)
.
Thus, for
𝐶
1
it requires
𝜃
1
≤
𝜃
2
𝑚
, and similarly for
𝐶
2
. The third subplot of Figure 2 depicts this decision area, where gray area denotes decision margin. However, the margin of A-Softmax is not consistent over all
𝜃
values: the margin becomes smaller as
𝜃
reduces, and vanishes completely when
𝜃
=
0
. This results in two potential issues. First, for difficult classes
𝐶
1
and
𝐶
2
which are visually similar and thus have a smaller angle between
𝑊
1
and
𝑊
2
, the margin is consequently smaller. Second, technically speaking one has to employ an extra trick with an ad-hoc piecewise function to overcome the nonmonotonicity difficulty of the cosine function.
LMCL (our proposed) defines a decision margin in cosine space rather than the angle space (like A-Softmax) by:
𝐶
1
:
cos
(
𝜃
1
)
≥
cos
(
𝜃
2
)
+
𝑚
,
𝐶
2
:
cos
(
𝜃
2
)
≥
cos
(
𝜃
1
)
+
𝑚
.
Therefore,
cos
(
𝜃
1
)
is maximized while
cos
(
𝜃
2
)
being minimized for
𝐶
1
(similarly for
𝐶
2
) to perform the large-margin classification. The last subplot in Figure 2 illustrates the decision boundary of LMCL in the cosine space, where we can see a clear margin(
2
𝑚
) in the produced distribution of the cosine of angle. This suggests that the LMCL is more robust than the NSL, because a small perturbation around the decision boundary (dashed line) less likely leads to an incorrect decision. The cosine margin is applied consistently to all samples, regardless of the angles of their weight vectors.
3.3Normalization on Features
In the proposed LMCL, a normalization scheme is involved on purpose to derive the formulation of the cosine loss and remove variations in radial directions. Unlike [23] that only normalizes the weight vectors, our approach simultaneously normalizes both weight vectors and feature vectors. As a result, the feature vectors distribute on a hypersphere, where the scaling parameter
𝑠
controls the magnitude of radius. In this subsection, we discuss why feature normalization is necessary and how feature normalization encourages better feature learning in the proposed LMCL approach.
The necessity of feature normalization is presented in two respects: First, the original softmax loss without feature normalization implicitly learns both the Euclidean norm (
𝐿
2
-norm) of feature vectors and the cosine value of the angle. The
𝐿
2
-norm is adaptively learned for minimizing the overall loss, resulting in the relatively weak cosine constraint. Particularly, the adaptive
𝐿
2
-norm of easy samples becomes much larger than hard samples to remedy the inferior performance of cosine metric. On the contrary, our approach requires the entire set of feature vectors to have the same
𝐿
2
-norm such that the learning only depends on cosine values to develop the discriminative power. Feature vectors from the same classes are clustered together and those from different classes are pulled apart on the surface of the hypersphere. Additionally, we consider the situation when the model initially starts to minimize the LMCL. Given a feature vector
𝑥
, let
cos
(
𝜃
𝑖
)
and
cos
(
𝜃
𝑗
)
denote cosine scores of the two classes, respectively. Without normalization on features, the LMCL forces
‖
𝑥
∥
(
cos
(
𝜃
𝑖
)
−
𝑚
)
>
‖
𝑥
∥
cos
(
𝜃
𝑗
)
. Note that
cos
(
𝜃
𝑖
)
and
cos
(
𝜃
𝑗
)
can be initially comparable with each other. Thus, as long as
(
cos
(
𝜃
𝑖
)
−
𝑚
)
is smaller than
cos
(
𝜃
𝑗
)
,
‖
𝑥
‖
is required to decrease for minimizing the loss, which degenerates the optimization. Therefore, feature normalization is critical under the supervision of LMCL, especially when the networks are trained from scratch. Likewise, it is more favorable to fix the scaling parameter
𝑠
instead of adaptively learning.
Furthermore, the scaling parameter
𝑠
should be set to a properly large value to yield better-performing features with lower training loss. For NSL, the loss continuously goes down with higher
𝑠
, while too small
𝑠
leads to an insufficient convergence even no convergence. For LMCL, we also need adequately large
𝑠
to ensure a sufficient hyperspace for feature learning with an expected large margin.
In the following, we show the parameter
𝑠
should have a lower bound to obtain expected classification performance. Given the normalized learned feature vector
𝑥
and unit weight vector
𝑊
, we denote the total number of classes as
𝐶
. Suppose that the learned feature vectors separately lie on the surface of the hypersphere and center around the corresponding weight vector. Let
𝑃
𝑊
denote the expected minimum posterior probability of class center (i.e.,
𝑊
), the lower bound of
𝑠
is given by 1:
𝑠
≥
𝐶
−
1
𝐶
log
(
𝐶
−
1
)
𝑃
𝑊
1
−
𝑃
𝑊
.
(6)
Based on this bound, we can infer that
𝑠
should be enlarged consistently if we expect an optimal
𝑃
𝑤
for classification with a certain number of classes. Besides, by keeping a fixed
𝑃
𝑤
, the desired
𝑠
should be larger to deal with more classes since the growing number of classes increase the difficulty for classification in the relatively compact space. A hypersphere with large radius
𝑠
is therefore required for embedding features with small intra-class distance and large inter-class distance.
3.4Theoretical Analysis for LMCL
Refer to caption
Figure 3:A geometrical interpretation of LMCL from feature perspective. Different color areas represent feature space from distinct classes. LMCL has a relatively compact feature region compared with NSL.
Refer to caption
Refer to caption
Figure 4:A toy experiment of different loss functions on 8 identities with 2D features. The first row maps the 2D features onto the Euclidean space, while the second row projects the 2D features onto the angular space. The gap becomes evident as the margin term
𝑚
increases.
The preceding subsections essentially discuss the LMCL from the classification point of view. In terms of learning the discriminative features on the hypersphere, the cosine margin servers as momentous part to strengthen the discriminating power of features. Detailed analysis about the quantitative feasible choice of the cosine margin (i.e., the bound of hyper-parameter
𝑚
) is necessary. The optimal choice of
𝑚
potentially leads to more promising learning of highly discriminative face features. In the following, we delve into the decision boundary and angular margin in the feature space to derive the theoretical bound for hyper-parameter
𝑚
.
First, considering the binary-classes case with classes
𝐶
1
and
𝐶
2
as before, suppose that the normalized feature vector
𝑥
is given. Let
𝑊
𝑖
denote the normalized weight vector, and
𝜃
𝑖
denote the angle between
𝑥
and
𝑊
𝑖
. For NSL, the decision boundary defines as
cos
𝜃
1
−
cos
𝜃
2
=
0
, which is equivalent to the angular bisector of
𝑊
1
and
𝑊
2
as shown in the left of Figure 3. This addresses that the model supervised by NSL partitions the underlying feature space to two close regions, where the features near the boundary are extremely ambiguous (i.e., belonging to either class is acceptable). In contrast, LMCL drives the decision boundary formulated by
cos
𝜃
1
−
cos
𝜃
2
=
𝑚
for
𝐶
1
, in which
𝜃
1
should be much smaller than
𝜃
2
(similarly for
𝐶
2
). Consequently, the inter-class variance is enlarged while the intra-class variance shrinks.
Back to Figure 3, one can observe that the maximum angular margin is subject to the angle between
𝑊
1
and
𝑊
2
. Accordingly, the cosine margin should have the limited variable scope when
𝑊
1
and
𝑊