Understanding Contrastive Learning Through the Lens of Margins

Daniel Rho, TaeSoo Kim, Sooill Park, Jaehyun Park, JaeHan Park
6/20/2023
cs.LG

No confident code implementation found for this paper.

Abstract

Contrastive learning, along with its variations, has been a highly effective self-supervised learning method across diverse domains. Contrastive learning measures the distance between representations using cosine similarity and uses cross-entropy for representation learning. Within the same framework of cosine-similarity-based representation learning, margins have played a significant role in enhancing face and speaker recognition tasks. Interestingly, despite the shared reliance on the same similarity metrics and objective functions, contrastive learning has not actively adopted margins. Furthermore, decision-boundary-based explanations are the only ones that have been used to explain the effect of margins in contrastive learning. In this work, we propose a new perspective to understand the role of margins based on gradient analysis. Based on the new perspective, we analyze how margins affect gradients of contrastive learning and separate the effect into more elemental levels. We separately analyze each and provide possible directions for improving contrastive learning. Our experimental results demonstrate that emphasizing positive samples and scaling gradients depending on positive sample angles and logits are the keys to improving the generalization performance of contrastive learning in both seen and unseen datasets, and other factors can only marginally improve performance.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{rho2023understanding,
  title  = {Understanding Contrastive Learning Through the Lens of Margins},
  author = {Daniel Rho and TaeSoo Kim and Sooill Park and Jaehyun Park and JaeHan Park},
  year   = {2023},
  eprint = {2306.11526},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2306.11526v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.11526.svg)](https://codeofpaper.com/paper/2306.11526)

Discussion