Contrastive Representation Learning 제 1부

이준석·2022년 8월 16일
0

링크 : https://lilianweng.github.io/posts/2021-05-31-contrastive/

The goal of contrastive representation learning is to learn such an embedding space in which similar sample pairs stay close to each other while dissimilar ones are far apart.
대조 표현 학습의 목표는 유사한 샘플 쌍이 서로 가깝게 유지되는 반면 유사하지 않은 샘플 쌍은 멀리 떨어져 있는 임베딩 공간을 학습하는 것입니다.

Contrastive learning can be applied to both supervised and unsupervised settings. When working with unsupervised data, contrastive learning is one of the most powerful approaches in self-supervised learning.
대조 학습은 지도 및 비지도 설정 모두에 적용할 수 있습니다. 비지도 데이터로 작업할 때 대조 학습은 자기 지도 학습에서 가장 강력한 접근 방식 중 하나입니다.

Contrastive Training Objectives

In early versions of loss functions for contrastive learning, only one positive and one negative sample are involved. The trend in recent training objectives is to include multiple positive and negative pairs in one batch.
대조 학습을 위한 손실 함수의 초기 버전에서는 하나의 긍정적인 샘플과 하나의 부정적인 샘플만 포함됩니다. 최근 훈련 목표의 경향은 하나의 배치에 여러 개의 긍정적인 쌍과 부정적인 쌍을 포함하는 것입니다.

Contrastive Loss

Contrastive loss (Chopra et al. 2005) is one of the earliest training objectives used for deep metric learning in a contrastive fashion.
Contrastive loss(Chopra et al. 2005)는 대조 방식의 심층 메트릭 학습에 사용되는 초기 훈련 목표 중 하나입니다.


Given a list of input samples , each has a corresponding label among classes.
입력 샘플 목록이 주어지면 각 클래스에는 해당 레이블이 있습니다.
Given a list of input samples {xi}\{x_i\}, each has a corresponding label yi{1,...,L}y_i \in \{1, ..., L\} among LL classes.
입력 샘플 {xi}\{x_i\}의 목록이 주어지면 각각은 LL 클래스 중에서 해당 레이블 yi{1,...,L}y_i \in \{1, ..., L\}를 갖습니다.

We would like to learn a function fθ(.):XRdf_{\theta}(.): \mathcal{X} \rightarrow \mathbb R^d that encodes xix_i into an embedding vector such that examples from the same class have similar embeddings and samples from different classes have very different ones.
동일한 클래스의 예제가 유사한 임베딩을 갖고 다른 클래스의 샘플이 매우 다른 임베딩을 갖도록 xix_i를 임베딩 벡터로 인코딩하는 함수 fθ(.):XRdf_{\theta}(.): \mathcal{X} \rightarrow \mathbb R^d를 배우고 싶습니다.

Thus, contrastive loss takes a pair of inputs (xi,xy)(x_i, x_y) and minimizes the embedding distance when they are from the same class but maximizes the distance otherwise.
따라서 대조 손실은 한 쌍의 입력 (xi,xy)(x_i, x_y)를 취하고 동일한 클래스에 속할 때 임베딩 거리를 최소화하지만 그렇지 않으면 거리를 최대화합니다.

Lcont(xi,xj,θ)=1[yi=yj]fθ(xj)22+1[yiyj]max(0,ϵfθ(xi)fθ(xj)2)2\mathcal L_{cont}(\mathbb x_i, \mathbb x_j, \theta)=1[y_i = y_j] \parallel f_{\theta}(x_j)\parallel^2_2+1[y_i \ne y_j] \max(0, \epsilon-\parallel f_{\theta}(x_i)-f_{\theta}(x_j)\parallel_2)^2

where ϵ\epsilon is a hyperparameter, defining the lower bound distance between samples of different classes.
여기서 ϵ\epsilon는 다른 클래스의 샘플 간의 하한 거리를 정의하는 하이퍼파라미터입니다.

Triplet Loss

profile
인공지능 전문가가 될레요

0개의 댓글