Processing math: 100%
본문 바로가기
논문 리뷰/Research Paper

Contrastive Clustering

by xi2d 2025. 3. 5.
반응형

[Submitted 18 May 2021]

Abstract

    Contrastive clustering (CC)라는 online clustering 방법을 제안하며, 이는 feature space에서 row와 column space에서 각각 instance- 및 cluster-level contrastive learning을 수행함. feature matrix의 row가 instance의 soft label로 간주될 수 있으며, 이에 따라 column은 cluster representation으로 간주되어 representation 학습과 cluster 할당을 end-to-end 방식으로 공동 학습함. 추가적으로, 제안된 방법은 데이터가 stream 형태로 제공될 때에도, 각 개별 instance에 대한 cluster 할당을 즉시 계산 가능함. CC는 여섯 개의 어려운 이미지 벤치마크에서 17개의 경쟁적인 clustering 방법을 현저하게 능가함. 

 

1. Introduction

    Representation 학습과 clustering을 end-to-end 방식으로 수행하는 방법에 대한 관심이 높아지면서 많은 연구들이 수행되었지만, 기존 방법들은 representation 학습과 clustering 과정 사이에서 발생하는 오류가 누적될 수 있으며, 전체 데이터셋을 기반으로 clustering을 수행하는 offline 방식에만 적용이 가능함. 따라 본 연구에서는 이러한 한계를 극복하기 위해 dual contrastive learning를 사용하여 feature matrix를 학습하며, 이 matrix의 row와 column은 각각 instance 및 cluster representation에 대응됨.

 

Contribution

  • Feature matrix의 column과 row가 instance 및 cluster representation과 대응된다는 사실을 최초로 규명함. 이를 통해 딥 clustering을 representation 학습 프레임워크에 통합 가능함.
  • 기존 contrastive learning 연구들과 달리, 제안된 dual contrastive learning 프레임워크는 instance level뿐만 아니라 cluster level에서도 contrastive learning을 수행함. 
  • Online 및 end-to-end 방식으로 동작하며, 대규모 데이터셋 및 streaming 타입 데이터 처리에도 적합함.

 

A. Contrastive Learning

    기존 contrastive learning은 instance level에서만 학습을 수행하는 반면, 본 연구에서는 label을 representation으로 간주하여 instance 및 cluster level에서 수행함. 

 

B. Deep Clustering

    기존의 데이터 representation과 cluster 할당을 반복적으로 업데이트하는 2단계 방식들은 단계별 과정에서 발생하는 오류 누적의 위험성이 있고, clustering을 위해서는 전체 데이터셋을 필요로 하여, 대규모 및 online 시나리오에서 활용이 제한됨. 일부 online clustering 방법들이 제안되었으나, 이론적으로는 충분하나 대부분 설명하기 어려운 보조적 overclustering 기법에 크게 의존함. 

 

    기존 연구들은 딥 신경망의 representation 학습 능력을 활용하여 clustering을 수행하는 것에 초점을 맞춘 반면, 본 연구에서는 contrastive 샘플을 이중적으로 활용하여 clustering을 촉진하는 통합 프레임워크를 제안함. 이러한 clustering-oriented contrastive learning 패러다임은 cluster 간 similarity를 최소화하여 cluster를 보다 명확하게 분리하는 역할을 함.

 

3. Method

    instance 및 cluster level의 contrastive learning을 두 개의 독립적인 subspaces으로 decoupling하면 clustering 성능이 향상됨을 확인함. 이러한 decoupling strategy가 성능을 향상시키는 이유는, ICH와 CCH의 표현 학습 능력(representability)을 개선할 수 있기 때문으로 추정된다.

  • Pair Construction Backbone (PCB): 데이터 augmentation을 통해 데이터 pair를 구성함.
  • Instance-level Contrastive Head (ICH): feature matrix의 row space에서 instance level contrastive learning을 수행함.
  • Cluster-level Contrastive Head (CCH): feature matrix의 column space에서 cluster level contrastive learning을 수행함. 

 

A. Pair Construction Backbone

    주어진 데이터 instance xi에 대해 동일한 데이터 augmentation 집합 T에서 샘플링된 두 개의 확률적 변환 Ta,Tb를 적용함.

xai=Ta(Xi),    Xbi=Tb(xi)

 

    해당 연구에서는 ResizedCrop, ColorJitter, Grayscale, HorizontalFlip, and GaussianBlur까지 SimCLR 설정의 총 5개의 augementation 기법을 적용함.

 

  • ResizedCrop: 이미지를 랜덤 크기로 자르고 (crop) 다시 원래 크기로 리사이징(resize)함.
  • ColorJitter: 이미지의 밝기 (brightness), 대비 (contrast), 채도 (saturation)를 조정함.
  • Grayscale: 이미지를 흑백 (grayscale)로 변환함.
  • HorizontalFlip: 이미지를 수평으로 반전시킴 (horizontally flip).
  • GaussianBlur: Gaussian blur를 적용하여 이미지를 흐리게 처리함.

 

    위와 같이 augmented된 샘플 xai,xbi에 대해, ResNet34를 backbone으로 채택하여 feature를 추출함.

hai=f(xai),    hbi=f(xbi)

 

 

B. Instance-level Contrastive Head

1. How to Construct Positive and Negative Pairs

    일반 contrastive learning와 같이, 동일 class는 positive pair로 나머지는 negative pair로 간주함. 

  • postiive pairs: 동일한 instance에서 augmented된 샘플들 xai,xbi
  • negative pairs: 동일한 instance에서 augmented되지 않은 샘플들 2N2

 

2. Feature Transformation for Contrastive Loss

    feature matrix에서 직접 contrastive learning을 수행하지 않고, 2 layer MLP gI()를 쌓아 feature를 subspace로 매핑한 후, instance-level contrastive loss를 적용함.

zai=gI(hai)

 

3. Pairwise Similarity

    Pairwise similarity는 cosine similarity로 측정됨. 

  • k1,k2a,b
  • i,j[1,N]

 

4. Instance-Level Contrastive Loss

 

  • τI: instance-level temperature parameter

 

    모든 augmentation 샘플에 대해 loss을 계산하고, 전체 minibatch에서 평균을 취하여 최종 ICH loss를 정의함. SimCLR에서 사용된 NT-Xent loss와 동일한 구조를 가짐. 

 

C. Cluster-level Contrastive Head

1. How to Construct Positive and Negative Pairs

    label을 representation으로 간주하는 아이디어로부터 시작함. 주어진 데이터 샘플을 cluster 개수와 동일한 dimension의 space에 projection하면, 각 feature vector의 i-번째 요소는 해당 샘플이 i-번째 cluster에 속할 확률로 해석될 수 있음. 즉, 이 feature vector는 soft label을 나타냄. 

 

    Clustering 결과를 표현할 경우, minibatch size N, cluster 개수 M일 때, CCH의 output matrix를 다음과 같이 정의함. 

  • Augmentation 1에 대한 output matrix: YaRNxM
  • Augmentation 2에 대한 output matrix: YbRNxM
  • Yan,m: probability of sample n being assigned to cluster m

 

    각 샘플은 하나의 cluster에 속하므로, 이상적으로는 Ya의 각 row이 one-hot vector에 가까워야 함. Yai-번째 column은 i-번째 cluster의 representation으로 해석될 수 있으며, 따라서 모든 column이 서로 다르게 구별되어야 함.

 

    동일 cluster에 속한 것끼리 positive pair로 같은 cluster에 속하지 않은 것들은 negative pair로 간주함. 

  • postiive pairs: 동일한 cluster에서 augmented된 샘플들 ˆyai,ˆybi
  • negative pairs: 동일한 cluster에서 augmented되지 않은 샘플들 2N2

 

2. Feature Transformation for Contrastive Loss

    2-layer nonlinear MLP gC()를 사용하여, feature matrix를 M-dimension space로 변환함. 

yai=gc(hai)

 

  • yai: soft label of sample xai (the i-th row of Ya)
  • ˆyai: i-the column of Ya, representation of cluster i under the first data augmentation
  • ˆybi: representation of cluster i under the second data augmentation

 

3. Pairwise Similarity

    Pairwise similarity는 LCH와 동일하게 cosine similarity로 측정됨. 

  • k1,k2a,b
  • i,j[1,M]

 

4. Cluster-Level Contrastive Loss

  • τC: cluster-level temperature parameter

 

    모든 cluster 샘플에 대해 loss을 계산하고, 전체 minibatch에서 평균을 취하여 최종 CCH loss를 정의함. H(Y)는 cluster 할당 확률의 entropy loss로 정의되며, 모든 샘플이 하나의 cluster에 할당되는 trivial solution을 방지하기 위해 추가됨.

  • H(Y)=Mi=1[P(ˆyailogP(ˆyai)+P(ˆybi)logP(ˆybi)]
  • P(ˆyki)=1NNt=1Ykti,    ka,b

 

D. Objective Function

    ICH와 CCH를 동시에 업데이트함. 일반적으로 dynamic weight 파라미터를 추가하여 두 loss 간 균형을 조정할 수 있으나 실험적으로 단순한 덧셈만으로도 충분히 좋은 성능을 보임.

 

5. Experiments

A. Datasets

  • CIFAR-100는 20개의 super-classes만을 label로 사용함.
  • STL-10의 100000개의 unlabeled 샘플을 추가로 사용하여 ICH를 훈련함.

 

B. Implementation Details

    기존 연구들과의 비교를 위해 ResNet34를 backbone으로 사용하고, 모든 이미지를 224 x 224로 upscaling할 때 이미지가 흐려지는 효과가 발생하므로 CIFAR-10, CIFAR-100, STL-10, Tiny-ImageNet에서는 GaussianBlur augmentation은 제외함.

 

C. Evaluation Metrics

    Normalized Mutual Information (NMI), accuracy, Adjusted Rand Index (ARI)를 사용하며 모두 값이 클수록 좋은 clustering 성능을 의미함. 

 

D. Comparisons with State of the Arts

  • 제안된 Contrastive Clustering (CC)는 모든 데이터셋에서 기존 최신 기법들보다 뛰어난 성능을 달성함
  • 기존의 방법들은 representation 학습과 clustering을 분리하여 수행하거나, 특정 구조에 종속되는 반면, CC는 통합된 contrastive learning 프레임워크를 활용하여 보다 구별력 있는 representation 학습과 clustering이 가능함.

 

E. Qualitative Study

    ImageNet-10 데이터셋을 활용하여 두 가지 실험을 수행하고,

1. Analysis on Pair-wise Similarity

    훈련 과정에서 instance 및 cluster 수준에서 positive pairs과 negative pairs의 similarity가 어떻게 변화하는지 시각적으로 분석함.

 

 

  • 훈련이 진행될수록 positive pairs의 유사도가 증가하는 반면, negative pairs의 유사도는 낮은 수준을 유지함. positive pairs과 negative pairs 사이의 similarity interval이 충분히 크기 때문에 모델이 성공적으로 학습됨. 

 

  • positive instance pairs과 negative cluster pairs의 variance이 상대적으로 작은 반면, negative instance pairs와 positive cluster pairs의 분산은 상대적으로 큼.
    • negative instance pairs의 큰 variance: 같은 class를 공유하는 다른 샘플들이 positive pair로 분류될 수 있음. 이 경우, 이론적으로는 positive pair로 간주되어야 하지만, 학습 초기에 negative pair로 취급되는 경우가 발생함.
    • positive cluster pairs의 큰 variance: 서로 다른 데이터 증강 방법을 적용했을 때, cluster 할당이 일관되지 않게 변할 수 있음. 즉, 동일한 cluster의 샘플이라도 다른 augmentation 방법에 따라 다른 cluster에 할당될 가능성이 존재.
  • 최종적으로, 동일한 class에 속한 샘플들이 높은 similarity를 가지며, 다른 class와 명확히 구별됨.

 

 

2. Evolution of Instance Feature and Cluster Assignments

    t-SNE를 활용하여 feature matrix의 row space을 2D space로 projection함. point은 개별 샘플을, color은 CCH가 예측한 cluster label을 나타냄.

 

 

F. Ablation Study

1. Importance of Data Augmentation

    데이터 augmentation과 두 개의 contrastive learning head가 모델 성능에 미치는 영향을 분석함.

  • 데이터 augmentation을 적용할 경우 CC 모델의 성능이 크게 향상되지만, 없을 경우 모델의 성능이 현저히 저하됨.

 

2. Effect of Contrastive Head

    각 contrastive learning head를 개별적으로 제거한 후, clustering 성능 변화를 분석함.

 

  • CIFAR-10의 경우, ICH 단독으로도 비교적 높은 성능을 유지함. 이는 CIFAR-10이 상대적으로 단순한 이미지 데이터셋이기 때문에, 개별 샘플의 feature만 잘 학습해도 충분한 clustering 성능을 확보할 수 있음을 의미함.
  • ImageNet-10의 경우, CCH이 제거된 경우, 성능이 크게 저하됨. CCH가 cluster 구조를 형성하는 데 더 중요한 역할을 하며, 특히 복잡한 데이터셋에서는 CCH의 효과가 더 두드러짐을 의미함.
  • 두 개의 contrastive learning head는 상호 보완적으로 작용하며, 데이터셋의 복잡도에 따라 상대적인 중요도가 다름.

 

    CCH는 cluster 예측을 직접 수행하기 때문에, 새로운 데이터 포인트가 들어올 때 실시간으로 clustering이 가능함. 반면, ICH만 사용할 경우, clustering을 위해 별도로 k-means를 수행해야 하므로 online 환경에서 활용이 어려움. 따라서, 두 개의 contrastive learning head를 함께 사용해야 최상의 성능과 온라인 클러스터링 기능을 모두 확보할 수 있음.

 

6. Conclusion

    Feature matrix의 row와 column이 각각 instance와 cluster의 representation으로 해석될 수 있음을 발견하고, 이를 기반으로 ICH와 CCH가 융합된 contrastive learning 프레임워크를 개발함. 일부 label이 제공되는 환경에서 라벨이 없는 데이터의 representation 학습을 개선하기 위한 semi-supervised learning과 pre-trained cluster representation을 새 도메인에 적응하는 transfer learning 방식을 연구할 예정임. 

 

 

반응형

댓글