์ด๊ฒ์ ์ดํดํ๊ธฐ ์์, Max margin contrastive loss (Hadsell et al. 2006) takes a pair of embedding vectors z_i and z_j as inputs. It essentially equates the Euclidean distance* between them if they have the same label (y_i=y_j) and is otherwise equivalent to hinge loss, It has a margin parameter m > 0 to impose a lower bound on the distance : label ์ด ๊ฐ์ ๋, ๋ค๋ฅผ ๋ ๋๋ ์ ๊ฐ๊ฐ์ ๊ฑฐ๋ฆฌ๋ฅผ loss ์ ๋ฐ์. ์ ์ดํดํ๋ฉด ํธํ๋ค.
๊ทธ๋ฆฌ๊ณ m ์ ์กด์ฌ๋ฅผ ์ดํดํ๊ธฐ ์ํด์๋ ์๋ ๋ ์ํฉ์ ์๊ฐํด๋ณด๋ฉด ํธํ๋ค.
1.
m=0 ์ด๋ผ๊ณ ์น๊ณ label y_i ์ y_j ๊ฐ ๊ฐ๊ณ , y_i ์ y_k ๊ฐ ๋ฉ๋ฆฌ ๋จ์ด์ง ์ํฉ
2.
m=0 ์ด๋ผ๊ณ ์น๊ณ label y_i ์ y_j ๊ฐ ๊ฐ๊ณ , y_i ์ y_k ๋ ๊ฐ์ ์ํฉ
m ์ด ์๋ค๋ฉด ๋ ๊ฒฐ๊ณผ๋ ๋์ผํ๋ค. ํ์ง๋ง ํ์คํ ๊ฒ์ ์ฐ๋ฆฌ๊ฐ ๋ฐ๋ผ๋ ์ํฉ์ด 2๋ณด๋ค๋ 1์ ๊ฐ๊น๋ค๋ ์ฌ์ค์ด๋ค.
*๋ด์ฉ์ ๋ฐํ์ผ๋ก ์๊ฐํด๋ณด๋ฉด ์ฐ๋ฆฌ๋ ๋ฏธ๋ฆฌ ์๊ณ ์์ด์ผ ํ๋ ๊ฒ์ด ๋ฐ๋ก m ์ด๋ค. ์ด๊ฒ์ ๋ฏธ๋ฆฌ ์์์ผ, ์ ์ ํ loss ๋ฅผ ์ค๊ณํ ์ ์๋ ๊ฒ์ด๋ค. ๋ฐ์ดํฐ์
์ ํน์ฑ์ ํ์
ํ๋ฉด์, ์ ์ ํ m ์ ์ฐพ์๋ด๋ ๋ค์๊ณผ ๊ฐ์ ์์
์ Triplet mining ์ด๋ผ๊ณ ํ๋ค. easy: triplets with a loss of 0 because the negative is already more than a margin away from the anchor than the positive ์ธ ์ํฉ์ด๋ผ๋ฉด ๋น์ฐํ ๋ณํํ๋ ๊ฒ์ด ์์๊ฒ์ด๋ค. the FaceNet (Schroff et al. 2015) paper. Schroff et al. argued that triplet mining is crucial for model performance and convergence. They also found that the hardest triplets led to local minima early on in training, specifically resulted in collapsed models, whereas semi-hard triplets yields more stable results and faster convergence. ์ด๋ฏ๋ก hard: triplets where the negative is closer to the anchor than the positive ๋ ์ง์ํด์ผ ํ๋ค๊ณ ๋ฐํ์ ธ ์๊ณ , semi-hard: triplets where the negative lies in the margin ์ธ ์ํฉ์์ ์์ํด์ผ ํ๋ค๊ณ ํ๋ค.


