메뉴 바로가기 본문 바로가기

Self-supervised Learning 1편

  • 황현상
  • 2023.11.20

[들어가며]

최근 GPT 등의 대규모 언어 모델이 굉장히 뛰어난 성능을 보이고 있고, 또 빠른 속도로 발전하고 있습니다. 이렇게 뛰어난 성능을 보일 수 있었던 가장 근본적인 이유는 막대한 양의 unlabeled data를 이용할 수 있었기 때문입니다. 일반적으로 모델을 학습하기 위해서는 사람이 직접 만든 label이 포함된 데이터가 필요하기 때문에 인터넷 등 다양한 매체에서 수많은 데이터를 쉽게 접할 수 있음에도, 학습에 이용할 수 있는 건 극히 일부입니다. 최근의 언어 모델들은 라벨 없이도 언어에 대한 전반적인 이해를 학습할 수 있는 pretraining 방법의 적용을 통해 수많은 unlabeled data를 이용할 수 있게 되었고, 거대한 모델과 함께 좋은 성능을 달성합니다.

vision task에서도 이와 마찬가지로 unlabeled data를 이용해 모델의 성능을 개선해보고자 하는 시도들이 있어 왔고, 특히 self-supervised learning은 Yann LeCun 교수님이 주목하고 있는 분야로 유명합니다. 이 글에서는 vision 분야에서 self-supervised learning이 어떤 식으로 발전해 왔는지 살펴볼 예정입니다.

 

[Self-supervised learning이란]

본격적인 내용에 앞서, 기본적인 내용이긴 하지만 self-supervised learning이 뭔지에 대해 간략하게 짚고 넘어가도록 하겠습니다.

기계학습에서의 학습 방법을 분류하면 보통 크게 2가지(supervised, unsupervised)로 분류 가능합니다. supervised learning은 입력 데이터와 label 쌍 데이터를 이용하여, 입력에 대한 모델의 출력이 정답에 가까워지도록 훈련하는 방식을 말합니다. unsupervised learning은 입력 데이터만 가지고 있는 상태로 데이터 내의 패턴이나 특성 등을 파악하는 학습 방식입니다.

self-supervised learning은 별도의 label을 가지고 있지 않아도, 입력 데이터에서 얻을 수 있는 정보를 라벨 삼아 모델을 훈련하는 방법으로, label이 없는 데이터를 이용한다는 점에서 unsupervised learning에 포함되는 개념으로 볼 수 있습니다.

이 개념을 이해하기 쉽게 예를 들면, 최근의 언어 모델들은 전체 문장의 일부를 가린 뒤 가려진 부분에 어떤 내용이 있는지 예측하는 방식으로 모델을 학습합니다. 이 경우 문장에 대해 정의된 라벨 없이 그저 문장만으로도 모델의 학습이 가능하고, 가려진 부분을 정확하게 예측하기 위해 모델은 문장의 문맥 정보, 단어들 간의 관계 등 다양한 정보를 학습해야 합니다. 이러한 학습 형태가 바로 self-supervised learning 입니다.

vision 분야 또한 self-supervised learning을 통해 좋은 특성을 학습하기 위해서는 label의 역할을 할 수 있는 task를 잘 정의하는 것이 중요합니다. 이제부터는 self-supervised learning을 위해 기존 연구들이 어떤 방식으로 task를 정의해 왔는지 알아보겠습니다.


[Pretext task]

기존 연구에서 self-supervised learning을 위해 정의된 모델이 해결해야 할 문제를 pretext task라고 합니다. 최근의 SSL 연구의 트렌드는 뒤에 설명될 contrastive learning, non-contrastive learning이 주를 이루고 있기 때문에, 여기서는 간단하게 아이디어 정도만 살펴보도록 하겠습니다.

Discriminative Unsupervised Feature Learning with Exemplar Convolutional Neural Networks 논문(NIPS 2014) 에서는, 하나의 클래스에 대한 여러 이미지가 존재하는 기존 분류 문제와 달리, 하나의 이미지가 하나의 class라고 가정한 분류 문제를 학습합니다. 즉, 10,000장의 이미지가 있다면 10,000개의 클래스가 있는 분류 문제인 것입니다. 학습에 전체 이미지를 사용하는 것은 아니고, 랜덤하게 patch를 sampling 하고, augmentation을 수행한 입력 데이터를 사용합니다.

 

 

 

 

 

 

Unsupervised Visual Representation Learning by Context Prediction 논문(ICCV 2015)에서는 이미지에서 여러 개의 패치를 뽑아낸 후, 한 패치를 기준으로 다른 패치가 어느 방향에 위치할지 위치를 예측합니다.

 

 

 


 

 

이와 유사하게, Unsupervised Learning of Visual Representations by Solving Jigsaw Puzzles 논문(ECCV 2016)에서는 이미지에서 9개의 patch를 뽑고, 직쏘 퍼즐처럼 순서를 섞은 뒤 원래 배열을 추론하는 문제를 학습합니다.

 

 

 


 

 

Unsupervised Learning of Visual Representations using Videos 논문(ICCV 2015)에서는 이미지가 아닌 unlabeled video data를 사용합니다. 연속성을 갖는 비디오에 포함된 frame에는 동일한 특성을 갖는 patch가 포함될 것이라는 가정 하에 랜덤 patch들 중, 동일 객체면 feature의 거리가 짧아지고 다른 객체면 feature의 거리가 멀어지도록 triplet loss를 이용합니다.

 

 


 

 

 

한편, 이렇게 patch들 간의 특성을 비교하는 방법들 외에도 이미지에 특정 훼손을 가하고 원본 이미지를 복원하는 형태의 연구들도 존재합니다.

Context Encoders: Feature Learning by Inpainting 논문(CVPR 2016)에서는 이미지의 일부를 가리고, 가려진 부분을 복원하는 형태의 네트워크를 학습합니다.

 

 


 

 

 

또 다른 방법으로 Colorful Image Colorization 논문(ECCV 2016)과 Split-Brain Autoencoders: Unsupervised Learning by Cross-Channel Prediction 논문(CVPR 2017)에서는 gray scale image 혹은 다채널 이미지의 특정 채널의 입력에 대해 원래 색상을 복원하는 방식으로 학습을 진행합니다.

 

 

 


 

 

 

Unsupervised Representation Learning by Predicting Image Rotations 논문(ICLR 2018)과 Self-Supervised Representation Learning by Rotation Feature Decoupling 논문(ICML 2019)에서는 이미지를 회전한 후, 얼마나 회전되었는지 예측하는 방식을 사용하기도 합니다.

 

 


 

 

 

언급된 방법들 외에도 이미지에 인위적인 노이즈를 가해 이미지를 훼손시킨 후 원본 이미지를 복원하는 방법, text 데이터를 함께 이용하는 방법, clustering을 이용하는 방법, GAN 기반의 방법, 이 방법들을 조합해 사용하는 multi-task 기반의 방법 등 다양한 방법들이 존재합니다.

기존 연구들이 정의한 pretext task 들을 살펴보면 이미지의 context를 파악하지 못하면 풀 수 없는 문제로 모델을 학습했고, 의미 있는 결과를 보여줍니다.

하지만 self-supervised learning을 통해 supervised learning보다 좋은 representation이 학습되었다면 분류 문제에서도 기존에 비해 향상된 성능을 보여줘야 하지만 아쉽게도 이 방법들은 기존 supervised learning 방식의 성능을 뛰어넘진 못했습니다.


[마치며]

오늘은 딥러닝 분야의 최신 트렌드 중 하나인 self-supervised learning에 대해 알아보았습니다. 현재까지 언급된 방법들 이후 contrastive, non-contrastive 등의 학습 방법을 사용해 성능을 크게 개선한 모델들이 많이 존재합니다. 특히 최근의 방법들은 task에 최적화 된 데이터로 supervised learning을 수행한 모델보다도 훨씬 뛰어난 성능을 보이고, 심지어 classification, detection, segmentation 등 다양한 task에 쉽게 적용할 수 있도록 general 한 feature를 추출할 수 있는 능력을 보입니다. 다음 글에서는 이후 발전 과정에 대해 다뤄보겠습니다.



[Reference]

 

Alexey, Dosovitskiy, et al. "Discriminative unsupervised feature learning with exemplar convolutional neural networks." IEEE TPAMI 38.9 (2016): 1734-1747.
Doersch, Carl, Abhinav Gupta, and Alexei A. Efros. "Unsupervised visual representation learning by context prediction." Proceedings of the IEEE international conference on computer vision. 2015.
Wang, Xiaolong, and Abhinav Gupta. "Unsupervised learning of visual representations using videos." Proceedings of the IEEE international conference on computer vision. 2015.
Yang, Jianwei, Devi Parikh, and Dhruv Batra. "Joint unsupervised learning of deep representations and image clusters." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
Pathak, Deepak, et al. "Context encoders: Feature learning by inpainting." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
Zhang, Richard, Phillip Isola, and Alexei A. Efros. "Colorful image colorization." Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part III 14. Springer International Publishing, 2016.
Noroozi, Mehdi, and Paolo Favaro. "Unsupervised learning of visual representations by solving jigsaw puzzles." European conference on computer vision. Cham: Springer International Publishing, 2016.
Vincent, Pascal, et al. "Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion." Journal of machine learning research 11.12 (2010).
Gomez, Lluis, et al. "Self-supervised learning of visual features through embedding images into text topic spaces." Proceedings of the ieee conference on computer vision and pattern recognition. 2017.
Zhang, Richard, Phillip Isola, and Alexei A. Efros. "Split-brain autoencoders: Unsupervised learning by cross-channel prediction." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.
Larsson, Gustav, Michael Maire, and Gregory Shakhnarovich. "Colorization as a proxy task for visual understanding." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.
Noroozi, Mehdi, Hamed Pirsiavash, and Paolo Favaro. "Representation learning by learning to count." Proceedings of the IEEE international conference on computer vision. 2017.
Doersch, Carl, and Andrew Zisserman. "Multi-task self-supervised visual learning." Proceedings of the IEEE international conference on computer vision. 2017.
Kim, Dahun, et al. "Learning image representations by completing damaged jigsaw puzzles." 2018 IEEE Winter Conference on Applications of Computer Vision (WACV). IEEE, 2018.
Gidaris, Spyros, Praveer Singh, and Nikos Komodakis. "Unsupervised representation learning by predicting image rotations." arXiv preprint arXiv:1803.07728 (2018).
Ren, Zhongzheng, and Yong Jae Lee. "Cross-domain self-supervised multi-task feature learning using synthetic imagery." Proceedings of the IEEE conference on computer vision and pattern recognition. 2018.
Feng, Zeyu, Chang Xu, and Dacheng Tao. "Self-supervised representation learning by rotation feature decoupling." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2019.