Search
moon
sun

Supervised NT-Xent loss (Khosla et al. 2020), let's first look at the self-supervised version of NT-Xent loss. NT-Xent is coined by Chen et al. 2020 in the SimCLR paper and is short for "normalized temperature scaled cross entropy lossโ—normalized temperature-scaled cross entropy lossโ€. It is a modification of the multi-class N-pair loss with addition of the temperature parameter (๐œ) to scale the cosine similarities. Chen et al. found that an appropriate temperature parameter can help the model learn from hard negatives.

์ถœ์ฒ˜
์ˆ˜์ง‘์‹œ๊ฐ„
2021/08/14 11:01
์—ฐ๊ฒฐ์™„๋ฃŒ
1 more property
๐Ÿ“Œ
z_i ๋Š” ๋ฐ˜๋“œ์‹œ anchor ์ด๊ณ  ์—ฌ๊ธฐ์„œ z_j ๋Š” ๋ฐ˜๋“œ์‹œ positive sample ์ด๋‹ค. (NX-Xent loss ์ฐธ๊ณ  Supervised NT-Xent loss (Khosla et al. 2020), let's first look at the self-supervised version of NT-Xent loss. NT-Xent is coined by Chen et al. 2020 in the SimCLR paper and is short for "normalized temperature scaled cross entropy lossโ€ฃโ€. It is a modification of the multi-class N-pair loss with addition of the temperature parameter (๐œ) to scale the cosine similarities. Chen et al. found that an appropriate temperature parameter can help the model learn from hard negatives. ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ด๋‹ค.) ์–ธ๋œป z_j ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ์— negative sample ๋ฅผ ๋„ฃ์–ด ๋” ์ผ๋ฐ˜ํ™”์‹œ์ผœ๋„ ๋˜์ง€ ์•Š์„๊นŒ? ํ•˜๋Š” ์ƒ๊ฐ์ด ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ, ์ž˜ ์ƒ๊ฐํ•ด๋ณด๋ฉด z_j ์— posive ๊ฐ€ ๋“ค์–ด๊ฐ€๋“  negative ๊ฐ€ ๋“ค์–ด๊ฐ€๋“  -log(a/b) ์—์„œ ๋ถ„๋ชจ b ๋Š” ๋Œ€์ฒด์ ์œผ๋กœ ๋˜‘๊ฐ™์„ํ…Œ๊ณ  ๋ถ„์ž์ธ a ๋งŒ ๋ณ€ํ•˜๋Š”๋ฐ, a/b=1 ์ด์–ด์•ผ loss=0 ์ด๋ฏ€๋กœ Optimal ์ด๋‹ค. ์ด ์ƒํƒœ๋กœ ํ›ˆ๋ จ์„ ์‹œํ‚ค๋Š” ๊ฒƒ์ด๋‹ค. ๋‹น์ดˆ ์ทจ์ง€๊ฐ€ โฌ†๏ธpositive / (positive_all + โฌ‡๏ธnegative_all) ๊ฐ€ 1 ์— ๊ฐ€๊นŒ์›Œ์ง€๋ก ๊ต์œก *๋ฐฉํ–ฅ โฌ†๏ธ ๊ณผ โฌ‡๏ธ ์€ ํ•ด๋‹น ์š”์†Œ๊ฐ€ ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”ํ–ˆ์œผ๋ฉด ์ข‹๊ฒ ๋‹ค๋Š” ์šฐ๋ฆฌ์˜ ๋ฐ”๋žŒ์ด๋‹ค. ์ธ๋ฐ ๋งŒ์•ฝ negative ๊ณผ anchor ์˜ ์œ ์‚ฌ๋„๊ฐ€ ๋ถ„์ž์— ๋“ค์–ด๊ฐ„๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ต์œก์„ ํ•˜๊ฒŒ ๋œ๋‹ค. โฌ†๏ธnegative / (โฌ‡๏ธpositive_all + โฌ‡๏ธnegative_all) ๊ฐ€ 1 ์— ๊ฐ€๊นŒ์›Œ์ง€๋„๋ก ๊ต์œก negative ์€ โฌ†๏ธ์ฆ๊ฐ€ํ•ด์•ผ ํ•˜๋Š”๋ฐ negative_all ์€ โฌ‡๏ธ๊ฐ์†Œํ•ด์•ผ ํ•œ๋‹ค๊ณ ? negative ์€ negative_all ์˜ ๋ถ€๋ถ„์ง‘ํ•ฉ์ด๋‹ค. ๊ฒŒ๋‹ค๊ฐ€ positive_all ์€ ์ฆ๊ฐ€ํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ผ์•ผํ•˜๋Š”๋ฐ ์ด ์‹์—์„œ๋Š” โฌ‡๏ธ๊ฐ์†Œํ•˜๊ธฐ๋ฅผ ๋ฐ”๋ผ๋ฏ€๋กœ ์ด๊ฑด ๋…ธ์ด์ฆˆ์ด๋‹ค. โ“loss ๋ฅผ ํ•ด์„ํ•  ๋•Œ ์ด๋ ‡๊ฒŒ (์ฐธ๊ณ 3) ์‹์˜ ์š”์†Œ๋ฅผ ๊ฐ๊ฐ, ๊ท€๋‚ฉ์ ์œผ๋กœ(?) ํ•ด์„ํ•ด๋„ ๋˜๋Š”๊ฑด๊ฐ€? ๋…ผ๋ฌธ (supervised contrastive loss โ€ฃ) ์—์„œ ์ด๊ฑธ ์—ญ์ „ํŒŒ์‹์œผ๋กœ ์œ ๋„ (์ฐธ๊ณ 1) ํ•˜๋Š” ๊ฒƒ์ด ๋‚˜์˜ค๋˜๋ฐ, ์ด๋Ÿฐ ์ง๊ด€๊ณผ ํ˜„์‹ค์ด ์กฐ๊ธˆ ๋‹ค๋ฅธ ๊ฒฝ์šฐ๋“ค์ด ์™•์™• ์กด์žฌํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ํ•ด๋‹น ๋…ผ๋ฌธ (์ฐธ๊ณ 2) ์„ ์ฐธ๊ณ ํ•ด์„œ ๊ฐœ๋…์„ ํ™•์‹คํžˆ ํ•˜๋Š”๊ฑด ์–ด๋–จ๊นŒ? ๊ด€๋ จ ์˜๋ฌธ (์ฐธ๊ณ 4)
์–˜๊ฐ€ ๋ฌด์กฐ๊ฑด supervised ๋ฐฉ์‹์œผ๋กœ ์‚ฌ์šฉ๋˜์–ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์€ ์•„๋‹˜. ์ถฉ๋ถ„ํžˆ unsupervised ๋กœ๋„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ.