Deep Learning

Dive into BYOL

응엉잉 2022. 8. 25. 11:23

1. Representation Learning

최종적으로 수행하려는 작업을 잘 하기 위해서 model이 입력 data의 특징을 잘 표현헐 수 있도록 훈련하는 것

image(입력 data)의 특징을 추출

 

2. Self-supervised Learning (SSL)

레이블이 없는 data를 활용하여 model이 좋은 representation을 추출할 수 있도록 학습하는 방법론

 step1. self-supervised 방식으로 model을 사전 학습

            사전학습 방식에 따라 pretext task / contrastive learning 으로 분류

 step2. 사전학습된 model의 downstream task로 전이 학습 진행

 

representation을 잘 배워서 downtstream task 에 잘 써먹는 것이 목표 !

 

3. contrastive learning

representation space 상에서 자신과 유사한 이미지와는 가까워지게, 자신과 다른 이미지와는 멀어지게 학습

pretext task 보다는 우수한 성능을 보이지만 negative pair 의 구성에 따라 성능이 달라짐

Argumentation 조합에 따라 model 의 성능이 크게 달라짐

 

1) MoCo : Memory Queue 를 이용해서 negative pair 구성

= 다량의 negative pair 얻기 위해 별도의 공간을 마련해서 negative pair 저장

 

2) SimCLR : batch size 크게 해서 negative sample 확보

 

수많은 negative sample과의 비교 과정이 있어야 contrastive learning의 성능이 좋아짐

-> negative pair를 사용하지 않는건 어떤지 !

 

4, Collapsed representation

positive pair로만 학습을 하는 경우 model이 constant vector를 출력하는 문제가 발생함 ( = collapsed representation)

한 image의 서로 다른 부분을 자른 2개의 image에서 나온 representation vector는 각 입력 image를 잘 표현 할 수 있어야 하고, 2개의 representation vector는 동일한 의미를 가져야 함 -> 두 image의 representation vector가 최대한 비슷해지는 방향으로 (MSE loss를 최소화하는 방향으로) 학습 진행 -> 학습이 잘못되면 입력 image가 어떠하든 고정된 숫자의 vector가 출력되도록 학습될 수 있음

ex) encoder가 무조건 0 vector만 출력하도록 학습하게 되면 어떤 image가 들어가도 loss = 0

 

1) contrastive loss

contrastive loss는 posivite 와 negative sample을 모두 사용하여 collapse를 방지함

positive pair간 유사도가 크고 negative pair간 유사도가 작을수록 loss 값 작아짐

 

2) BYOL

negative sample없이도 collapsed representation이 나오지 않도록 해야 함

(= positive pair만을 이용해도 좋은 representation을 얻을 수 있어야 하므로)

 

5. BYOL

1) core motivation of BYOL

A: random parameter + freeze encoder

A + linear layer 

ImageNet data로 학습시킨 model 정확도 -> 매우 낮음

 

B : random parameter + freeze encoder

B + linear layer 

A의 부정확한 prediction을 이용하여 학습시킨 model 정확도 -> 여전히 낮지만 대폭 향상

 

2) Architecture

공통된 image에 서로 다른 argumenation이 가해진 image( t, t' ) 가 각각의 input

online networktarget network로 구성, parameter update 방식이 다름

online network : encoder, projector, predictor

target network : encoder, projector

 

  * encoder : input image 특징(feature)을 추출, feature 담은 representation vector 출력

  * projector : representation vector를 projection vector로 바꿔서 loss 값 계산을 용이하게 함 

 

online network의 projection vector를 이용하여 target network 에서 나온 projection vector를 예측하는 과정 통해 학습

-> L2 loss (online nw의 proj. 와 target nw의 proj. 간 차이) 를 이용해서 다시 online network의 parameter update

-> online network의 weight들의 exponential moving average 사용해서 target network의 weight update

 

학습 완료 후에는 online network 의 encoder만 사용

 

3) exponential moving average

MoCo v2에서 사용하는 momentum update와 유사한 방식

cosine annealing을 사용하여 학습이 진행될수록 타우를 점점 1에 가까운 값으로 키움

 

self supervision을 활용한 image representation 추출

2개의 network 이용해 반복적으로 NW의 출력을 bootstrap

 

220831 추가

한 image의 다양한 view를 예측하는 과정을 통해 공통된 representation 학습

공통된 representation 학습하는 과정에서 모든 view에 대해 항상 같은 representation만 도출하는 representation collapse 발생할수도 있음

 

bootsrtap : online network가 target network의 representation을 반복적으로 학습하는 과정을 통해 양질의 representation을 뽑아냄

target network의 parameter는 online network의 parameter와의 moving exponential average로 update

 

 

 

'Deep Learning' 카테고리의 다른 글

momentum update  (0) 2022.08.30
loss back-propagating  (0) 2022.08.30
cv2  (0) 2022.08.19
lambda(), sort()에서 key와 lambda 사용하기  (0) 2022.08.18
os와 glob  (0) 2022.08.18