Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[103] Understanding Dimensional Collapse in Contrastive Self-supervised Learning (DirectCLR) #133

Open
dhkim0225 opened this issue Nov 4, 2022 · 0 comments

Comments

@dhkim0225
Copy link
Owner

dhkim0225 commented Nov 4, 2022

paper
code

Contrastive Learning (CL) 에서 Dimensional Collapse (DC) 발생.
non-CL method 들은 상대적으로 DC 가 덜 발생.

기존 CL 에선 nagtive sample pair 들을 이용해 DC 를 막음.
근데, DC 는 CL에서 여전히 발생하고 있음.
이를 해결할 수 있는 DirectCLR 을 제시.

Dimensional Collapse (DC)

DC 가 무엇인지 부터 알아보자.
image

model 에 의해 생성되는 embedding vector 들이 하나의 point 로 간다면, 이를 complete collapse (b) 라고 부른다.
CL 은 요건 잘 막아주긴 하지만, DC (c) 는 막아주지 못한다.

해당 논문에서 2-layer MLP projector로 SimCLR 을 imagenet에 100epoch 학습시켜 보았다.
간단히 얘기하면, (a) 방식이다.

validation set 에 대해서 embedding vector의 dimensionality 를 계산했다.
2개의 각 embedding vector는 dimension $d=128$ 을 지닌다.
covariance matrix $C \in R^{d \times d}$ 를 계산하고, 해당 matrix 의 singular value를 찍어보니,

image

띠용?
많은 양의 singular value 가 0에 가깝다. 즉, 128차원을 풀로 안 쓴다는 이야기.

DC by Strong Augmentation

augmentation 에서 발생하는 variance 가 data 의 variance 보다 크면, dimensional collapse 가 일어날 수 있다고 한다.

Linear Model

InfoNCE loss 를 예로 들어보자.
image

요 녀석들을 이용해 linear model 의 gradient $G$를 구해보면, (그냥 편미분)
image
image
image

여기서 $\alpha_{ij}$ 값은 두 벡터 사이의 similarity 값에 softmax 취한 값이다.
$\huge \alpha_{ij} = exp(-|z_i - z_j|^2 / 2) / Z_i$
$\huge \alpha_{ii} = exp(-|z_i - z_i^`|^2 / 2) / Z_i$
$\huge Z_i = W X_i$

$G$값들은 $g_z$ 들로 이루어져 있고 $g_z$ 들은 embedding vector $z$ 들로 이루어져 있다. embedding vector 는 linear model 기준, weight * input 이다. 수식으로는 다음과 같이 정리할 수 있다.
image

이걸 또 잘 정리해보면 (Lemma 2.), 다음과 같다.
image

(2023.03.20) 읽은 지 좀 오래된 내용이라 간단하게 정리해 두고 마무리 한다.
결국 CL 맥일 때, 2 layer projector 가 있으면 똑같이 문제가 해결되긴 하는데,
여기서는 왜 그런 현상이 발생하는가를 수식적으로, 실험적으로 증명한다.

결국 제안하는 것은, 마지막 representation 의 $d_0$ 만큼만 slice 해서 사용하자. 이다.
image

성능도 문제없이 잘 돌아간다.
image

실제로 사용할...필요성은 없다고 생각한다.
$d_0$ 도 튜닝이 필요하기 때문.
image

왜 dimensional collapse 가 일어나는가 를 심층적으로 잘 분석한 점이 이 논문의 의의이다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant