본문 바로가기
딥러닝 with Python

[딥러닝 with Python] Online Encoder, Momentum Encoder

by CodeCrafter 2025. 2. 27.
반응형

 

 Self-Supervised Learning(자기지도학습)에서는 레이블 없이 데이터의 특징을 효과적으로 학습하기 위해 Online Encoder와 Momentum Encoder를 활용합니다. 이 두 개념은 Representation Learning에서 중요한 역할을 하며, 특히 Contrastive Learning과 BYOL과 같은 방법론에서 핵심적인 요소로 작용합니다.

 

1. Online Encoder와 Momentum Encoder

1) Online Encoder

 

- Online Encoder는 데이터를 인코딩하여 feature embedding을 생성하는 주 네트워크입니다. 학습 과정에서 직접 가중치를 업데이트하며, Representation Learning의 핵심 요소로 작용합니다.

 

- 이는 일반적인 신경망 모델처럼 Gradient Descent를 이용해 지속적으로 가중치가 조정됩니다. 일반적인 Encoder라고 보시면 되겠습니다.

 

- 이를 수식으로 표현하면 아래와 같습니다.

 

 

2) Momentum Encoder

- Momentum Encoder는 모델의 가중치를 직접 업데이트하지 않고, Online Encoder의 가중치를 지수이동평균(EMA, Exponential Moving Average) 방식으로 업데이트하는 인코더입니다. 

 

- 즉, 학습 과정에서 Online Encoder의 변화를 부드럽게 반영하여 점진적으로 업데이트됩니다.

 

- 특징을 정리해보면 아래와 같습니다.

 * 직접 Backpropagation(역전파)로 학습되지 않으며, Online Encoder의 가중치를 기반으로 느리게 변화하는 구조를 가짐.

 * 모델 학습이 안정적으로 진행되도록 돕고, representation의 품질을 유지하는 데 기여함.
 * 지수 이동 평균을 사용하여 Online Encoder의 가중치를 유지하며 업데이트함.

 

-  Momentum Encoder의 가중치는 Online Encoder의 가중치를 EMA 방식으로 업데이트하는 것입니다.

 

 

Online Encoder와 Momentum Encoder에 대해 지금까지 알아본 내용을 정리하면 아래와 같습니다.

 

 

 

2. 활용 예시

1) MoCo (Momentum Contrast)

https://arxiv.org/pdf/1911.05722

 

 

- MoCo는 Contrastive Learning 기반의 방법으로, Momentum Encoder를 활용하여 더 큰 dictionary(Queue)를 유지하면서 안정적인 representation을 학습합니다.

 * Online Encoder는 Query 데이터를 처리하고, Momentum Encoder는 Key 데이터를 처리함.
 * Query-Key 쌍을 Contrastive Loss를 이용해 구별하도록 학습.
 * Momentum Encoder는 Online Encoder를 부드럽게 따라가면서 안정적인 feature representation을 유지.

 

 

2) BYOL (Bootstrap Your Own Latent)

https://arxiv.org/pdf/2006.07733

- BYOL은 Contrastive Loss 없이도 representation을 학습할 수 있는 방법으로, Online Encoder와 Momentum Encoder를 사용하여 자기지도학습을 수행합니다.

 

 * Online Encoder와 Momentum Encoder의 출력을 서로 예측하도록 학습.
 * Momentum Encoder가 생성한 feature를 Online Encoder가 예측하도록 함. 
 * Momentum Encoder의 가중치는 EMA 방식으로 유지.

반응형

댓글