카테고리 없음

A Simple Framework for Contrastive Learning of Visual Representations

도그사운드 2025. 2. 10. 15:05

A Simple Framework for Contrasitive Learning of Visual Representations (3).pdf
1.34MB

 

SimCLR에 대한 arXiv 저널 정리

 

2020.6월에 구글 리서치에서 발표한 자료

https://arxiv.org/abs/2002.05709

 

A Simple Framework for Contrastive Learning of Visual Representations

This paper presents SimCLR: a simple framework for contrastive learning of visual representations. We simplify recently proposed contrastive self-supervised learning algorithms without requiring specialized architectures or a memory bank. In order to under

arxiv.org

 

SimCLR은 시각적 이미지를 대조학습하는 프레임웍이다.

영상분석에서 라벨링이 필요하다는 문제를 해결해준것이다.

이미지에서 다양한 특성을 학습한 후에, 소량의 라벨링 데이터를 입력하면 이를 기반으로 판별해준다. 그러나 학습 과정은 판별(discriminative)이 아닌 생성(generative)에 해당한다. 생성은 새로 만들거나 픽셀을 늘리는 것으로 보면 되는데 후자에 속한다고 볼 수 있다.

ImageNet을 테스트하면 이와 같이 자가학습 알고리즘 대비 성능이 우수하다고 함

A linear classifier trained on self-supervised representations learned by SimCLR achieves 76.5% top-1 accuracy, which is a 7% relative improvement over previous state-ofthe-art, matching the performance of a supervised ResNet-50. When fine-tuned on only 1% of the labels, we achieve 85.8% top-5 accuracy, outperforming AlexNet with 100× fewer labels.

SimCLR알고리즘은 이미지넷으로 테스트했을 때 76.5%의 정확도를 보여 현재 가장 잘 나가는 ResNet507%보다 우수했다. 만약 1%의 데이터에 레이블을 붙이며 85.8%의 정확도를 보였다. 알렉사넷의 (100x일부레이블) 보다 탁월한 성능을 보였다.

 

이와 같은 구조로 변환 t~T를 거친다. 이 변환은 확률적데이터증강(stochastic data augmentation)을 거쳐서 positive pair와 negative pair를 만든다.

손실함수는 NT-Xent(Normalized Temperature-scaled Cross Entropy) loss다.

sim은 두 positive pair의 유사성, r은 온도(gpt api의 그 온도와 유사), N은 샘플 수다.

이 함수는 positive pair의 내적 inner product를 높여 두 임베딩 값이 유사하게 만들고, 다른 negative와는 유사도를 -1에 가깝게 만들어 잘 분리되게 만들기 위한 것이다.

 

학습한 데이터를 latent vetor space에 할당하는 것이다. LDA의 latent는 선형이나 SimCLR은 비선형이란 차이점은 있다.

LDA의 원리를 본적이 오래되서 선형이었는지 아닌지 잘 모르겠다.

 

이 학습과정에서의 증강은 랜덤크롭, 확률적이니까 랜덤이다. 랜덤색상왜곡, 랜덤가우시안블러의 증강이 사용된다.

torchvision 명령으로 예를 들자면

transforms.RandomRotation(degrees=15)

transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.1)

이런 것이라 보면 되겠다.

개대가리, 개뒷다리로 개새끼임을 판별한다

Stochastic Data Augmentation   Encoder Network   Projection Head   Contrasitive Loss
positive pair를 생성한다.
랜덤 크롭, 랜덤 리사이즈 등을 사용하는데 저자는 random color distortion이 가장 성능이 우수하다고 함
증폭 이미지로부터 벡터 추출, ResNet-50과 같은 CNN을 사용 인코더 출력을 latent vector space에 할당
2 layer MLP에 ReLU
NT-Xent Loss 함수 활용

 

학습과정

배치크기를 256~8192까지 변경시켰는데 배치가 클수록 negative 증가에 따라 성능향상

 

깃허브에 코드가 등재되어있다.

https://github.com/google-research/simclr

 

GitHub - google-research/simclr: SimCLRv2 - Big Self-Supervised Models are Strong Semi-Supervised Learners

SimCLRv2 - Big Self-Supervised Models are Strong Semi-Supervised Learners - google-research/simclr

github.com

근데 코드가 5년전에 등재되어 있네. 충돌 많을 것 같음