Introduction
저자들이 선택한 scene undurstanding task ( 장면에 대한 이해) 의 in context learning의 3가지 구성요소
- generality
- data efficiency
- fast adaptation
NN 검색 method를 이용하여 dense scene undertanding task의 성능 향승을 보임(기존에 취약한 부분)
이를 이용한 retrieval-based decoding mechanism - task specific parameter나 finetuning 필요 x
⇒ standard encoder에 적용하는데 추가적인 노력 불필요 (ResNet 이던 ViT던 적용가능)
모델 성능을 증진하기 위한 두 가지 pretraining components 제시
- contextual pretraining⇒ attention across image(뒤에서 설명)
- standard self-supervised pretraining protocol에서 간단한 변화
- spatial attention pooling mechanism
Method

Retrieval-based scene understanding
general-purpose image representation은 다양한 scene understanding 작업에서 즉각적으로 수행되어야 함 ( 파라미터 수정 없이)
⇒ 이러한 조건에 만족하도록 하기 위해 standardd image-level NN(nearest neighbor) retrieval 이용
training images와 해당 labels 로 구성된 prompt 주어짐(x가 image, y가 label)
$$ \{(x_i, y_i),i = 1, ... , N, x_i \in \mathbb R^{H' \times W' \times C} \} $$
목표 : pretrained image encoder $f_\theta$가 test set의 새로운 Image x 에 대한 prediction을 만들수 있도록
y에 대한 설명이 뒤에 쭈르륵 나오는데 무슨 말인지 잘 모르겠…(추후 이해되면 추가 예정)
1)
각 Prompt image 를 spatially flattened map($k_i = f_\theta(x_i)\in \mathbb R^{H\cdot W \times D}$)으로 encoding
feature $k_i^j \in \mathbb R^D$는 특정 위치 j는 patch의 pixel label $y_i^j$를 평균내서 생성한 local label $l_i^j$와 함께 정렬됨
⇒ 확실하진 않지만 개인적인 해석 - 이 논문에서는 패치를 16 x 16으로 고정했다고 함
k는 그냥 image를 flatten 시킨 map 인것 같고 Image에서 특정 위치 j를 고르면 그 위치에 해당하는 patch 내 pixel label을 평균시켜서 얻어낸 것이 $l_i^j$이라는 뜻 같음
각 Image에서 subset of feature와 local label의 경우 sampling
⇒ memory bank $\mathcal M$의 key 와 value를 형성한다고 함(sampling distribution인 $\mathcal S$는 appendix 참고)
$$ \mathcal M = \{ (k_i^j, l_i^j), i = 1, ... , N, j \sim \mathcal S\} $$
In the following, we do not distinguish between entries from different images, and use a single integer j to index into the memory bank (이해 못함 추후추가)
$$ \mathcal M = \{(k^j, l^j), j = 1, ..., |\mathcal M|\} $$
2)
- test image x 에 대해 represetation $q = f_\theta (x)$ 생성
- temperature $\beta$ 포함해 feature $q^i$를 memory bank 와 cross attention
⇒ local prediction $\hat l^i$
$$ s^{i,j} = {1\over \beta} {\left\langle q^i, k^j \right\rangle \over ||q^i|| ||k^j||}, \qquad a^i = \text{softmax}_j(s^i), \qquad \hat l ^i = \sum_j a^{i,j}l^j $$
다시 말해 cross-attention operation $\hat l^i = \text{CA} (q^i, k^j, l^j)$
⇒ 최종 prediction $\hat y$는 local preddiction $\hat l^i$를 concatenation 하고 Upsampling해 original image size로
결과적으로, nearest neighbor retrieval 을 통해 추가적인 decoder나 parameter adaptation 없이 scene understanding task 수행할 수 있게됨
정리를 해보면, 위에서 encoding하고 patch 내에서 class label 수집하고 했던게 encoding 된 feature가 동일한 클래스 끼리는 가까이 분포한다는 가정으로 거기 내에서 cross attention을 진행했다는 것 같음
Contextual pretraining
위에서 제시한 체제에서 모델이 잘 수행하기 위한 방법론 제시
우선 Memory bank $\mathcal M_p = \{(k_i, v_i), i = 1, ..., |\mathcal M_p|\}$를 이전 batch에서 training image $x_i$에서 계산된 spatially averaged key 와 value로 채움
$$ h_i = f_\theta(x_i) \in \mathbb R^{H\cdot W \times D}, \qquad k_i = {1\over H\cdot W} \sum^{H\cdot W}{j=1} h_i^j \in \mathbb R^D, \qquad v_i = \phi\theta(k_i) \in \mathbb R^D $$
value head $\phi_\theta$를 MLP로 사용 (자세한 detail은 appendix B 참고)
새로운 training image x 의 representation $q = f_\theta(x)$ 형성, 각 feature를 query로 이용
⇒ update $\hat v^i = \text{CA} (q^i, k_j, v_j)$
각 feature 는 “contextualized” ⇒ $c^i = \psi_\theta ((1-\lambda){q^i\over ||q^i||} + \lambda {\hat v^i \over ||\hat v^i ||})$ $\psi_\theta$는 linear layer, $\lambda$는 parameter
⇒ contextualized image representation $c = g_\theta(q, \mathcal M_p)$ 형성(그냥 Local $c^i$ concatenation)
여기서 나오는 $\mathcal M_p$는 train 이용, $\mathcal M$은 test에 이용. 둘이 엄연히 다름!
self-supervised objective

Image에서 attention 통한 학습이 dense task에서 필요한 fine-grained prediction을 가능하게 한다고 가정
이 가정을 해결하기 위해 attention pooling과 contrastive learning을 함께 사용해 image에서 가장 distinctive한 부분을 locate 하기 위해 representation 학습
2가지 논문을 이용한 방법을 쓰는데 나중에 읽어보자..
unlabeled image x 를 random data augmentation을 통해 다른 view 두 개 생성(AppendixC.1 확인)
$$ x_1 \sim A_1(x), x_2 \sim A_2(x) $$
각 vie는 ecoded $h_i = f_\theta(x_i)$,contextualized $c_i = g_\theta(h_i, \mathcal M_p) \in \mathbb R^{H\cdot W\times D}$ (위 그림 참고)
마지막으로 pooliing 적용해 representation $\hat c_i \in \mathbb R^D$를 얻어냄
$$ m_i = \text{softmax}j (a\theta(c_i)), \qquad \hat c_i = \sum^{H\cdot W}{j=1} m_i^j \omega\theta(c_i^j), \qquad z_i^\theta = p_\theta(\hat c_i) $$
m은 lightweight attention module $a_\theta$를 통해 얻은 Mas
$\omega_\theta$는 additional value head
$p_\theta$는 Pooling이라고 생각하면 됨
그다음에는 논문 3가지에 언급된 방법 이용(1개는 위 2개 중 하나와 겹침)
각 view가 - 다른 view의 target $z_j^\xi$에 대한 예측 $q_\theta(z_i^\theta)$ 형성
이는 동일한 achitecture 와 더 천천히 변하는 가중치 $\xi$ 집합으로 계산된다는데 appendix C.2를 보자
이를 통한 standard contrastive loss:
$$ \mathcal L_\text{SSL}^{ij}(\theta;\xi) = -\log{\exp(q_\theta(z_i^\theta)\cdot z_j^\xi) \over \exp(q_\theta(z_i^\theta) \cdot z_i^\xi) + \sum_k \exp(q_\theta(z_i^\theta) \cdot z_k^\xi)} $$
뒷부분은 이제 정리 느낌인데 이전 논문 2개 와 loss 도출 과정에 필요한 논문 4개 정리 후에 appendix내용과 함꼐 추가 보강 하겠음!
Introduction
저자들이 선택한 scene undurstanding task ( 장면에 대한 이해) 의 in context learning의 3가지 구성요소
- generality
- data efficiency
- fast adaptation
NN 검색 method를 이용하여 dense scene undertanding task의 성능 향승을 보임(기존에 취약한 부분)
이를 이용한 retrieval-based decoding mechanism - task specific parameter나 finetuning 필요 x
⇒ standard encoder에 적용하는데 추가적인 노력 불필요 (ResNet 이던 ViT던 적용가능)
모델 성능을 증진하기 위한 두 가지 pretraining components 제시
- contextual pretraining⇒ attention across image(뒤에서 설명)
- standard self-supervised pretraining protocol에서 간단한 변화
- spatial attention pooling mechanism
Method
Retrieval-based scene understanding
general-purpose image representation은 다양한 scene understanding 작업에서 즉각적으로 수행되어야 함 ( 파라미터 수정 없이)
⇒ 이러한 조건에 만족하도록 하기 위해 standardd image-level NN(nearest neighbor) retrieval 이용
training images와 해당 labels 로 구성된 prompt 주어짐(x가 image, y가 label)
$$ \{(x_i, y_i),i = 1, ... , N, x_i \in \mathbb R^{H' \times W' \times C} \} $$
목표 : pretrained image encoder $f_\theta$가 test set의 새로운 Image x 에 대한 prediction을 만들수 있도록
y에 대한 설명이 뒤에 쭈르륵 나오는데 무슨 말인지 잘 모르겠…(추후 이해되면 추가 예정)
1)
각 Prompt image 를 spatially flattened map($k_i = f_\theta(x_i)\in \mathbb R^{H\cdot W \times D}$)으로 encoding
feature $k_i^j \in \mathbb R^D$는 특정 위치 j는 patch의 pixel label $y_i^j$를 평균내서 생성한 local label $l_i^j$와 함께 정렬됨
⇒ 확실하진 않지만 개인적인 해석 - 이 논문에서는 패치를 16 x 16으로 고정했다고 함
k는 그냥 image를 flatten 시킨 map 인것 같고 Image에서 특정 위치 j를 고르면 그 위치에 해당하는 patch 내 pixel label을 평균시켜서 얻어낸 것이 $l_i^j$이라는 뜻 같음
각 Image에서 subset of feature와 local label의 경우 sampling
⇒ memory bank $\mathcal M$의 key 와 value를 형성한다고 함(sampling distribution인 $\mathcal S$는 appendix 참고)
$$ \mathcal M = \{ (k_i^j, l_i^j), i = 1, ... , N, j \sim \mathcal S\} $$
In the following, we do not distinguish between entries from different images, and use a single integer j to index into the memory bank (이해 못함 추후추가)
$$ \mathcal M = \{(k^j, l^j), j = 1, ..., |\mathcal M|\} $$
2)
- test image x 에 대해 represetation $q = f_\theta (x)$ 생성
- temperature $\beta$ 포함해 feature $q^i$를 memory bank 와 cross attention
⇒ local prediction $\hat l^i$
$$ s^{i,j} = {1\over \beta} {\left\langle q^i, k^j \right\rangle \over ||q^i|| ||k^j||}, \qquad a^i = \text{softmax}_j(s^i), \qquad \hat l ^i = \sum_j a^{i,j}l^j $$
다시 말해 cross-attention operation $\hat l^i = \text{CA} (q^i, k^j, l^j)$
⇒ 최종 prediction $\hat y$는 local preddiction $\hat l^i$를 concatenation 하고 Upsampling해 original image size로
결과적으로, nearest neighbor retrieval 을 통해 추가적인 decoder나 parameter adaptation 없이 scene understanding task 수행할 수 있게됨
정리를 해보면, 위에서 encoding하고 patch 내에서 class label 수집하고 했던게 encoding 된 feature가 동일한 클래스 끼리는 가까이 분포한다는 가정으로 거기 내에서 cross attention을 진행했다는 것 같음
Contextual pretraining
위에서 제시한 체제에서 모델이 잘 수행하기 위한 방법론 제시
우선 Memory bank $\mathcal M_p = \{(k_i, v_i), i = 1, ..., |\mathcal M_p|\}$를 이전 batch에서 training image $x_i$에서 계산된 spatially averaged key 와 value로 채움
$$ h_i = f_\theta(x_i) \in \mathbb R^{H\cdot W \times D}, \qquad k_i = {1\over H\cdot W} \sum^{H\cdot W}{j=1} h_i^j \in \mathbb R^D, \qquad v_i = \phi\theta(k_i) \in \mathbb R^D $$
value head $\phi_\theta$를 MLP로 사용 (자세한 detail은 appendix B 참고)
새로운 training image x 의 representation $q = f_\theta(x)$ 형성, 각 feature를 query로 이용
⇒ update $\hat v^i = \text{CA} (q^i, k_j, v_j)$
각 feature 는 “contextualized” ⇒ $c^i = \psi_\theta ((1-\lambda){q^i\over ||q^i||} + \lambda {\hat v^i \over ||\hat v^i ||})$ $\psi_\theta$는 linear layer, $\lambda$는 parameter
⇒ contextualized image representation $c = g_\theta(q, \mathcal M_p)$ 형성(그냥 Local $c^i$ concatenation)
여기서 나오는 $\mathcal M_p$는 train 이용, $\mathcal M$은 test에 이용. 둘이 엄연히 다름!
self-supervised objective
Image에서 attention 통한 학습이 dense task에서 필요한 fine-grained prediction을 가능하게 한다고 가정
이 가정을 해결하기 위해 attention pooling과 contrastive learning을 함께 사용해 image에서 가장 distinctive한 부분을 locate 하기 위해 representation 학습
2가지 논문을 이용한 방법을 쓰는데 나중에 읽어보자..
unlabeled image x 를 random data augmentation을 통해 다른 view 두 개 생성(AppendixC.1 확인)
$$ x_1 \sim A_1(x), x_2 \sim A_2(x) $$
각 vie는 ecoded $h_i = f_\theta(x_i)$,contextualized $c_i = g_\theta(h_i, \mathcal M_p) \in \mathbb R^{H\cdot W\times D}$ (위 그림 참고)
마지막으로 pooliing 적용해 representation $\hat c_i \in \mathbb R^D$를 얻어냄
$$ m_i = \text{softmax}j (a\theta(c_i)), \qquad \hat c_i = \sum^{H\cdot W}{j=1} m_i^j \omega\theta(c_i^j), \qquad z_i^\theta = p_\theta(\hat c_i) $$
m은 lightweight attention module $a_\theta$를 통해 얻은 Mas
$\omega_\theta$는 additional value head
$p_\theta$는 Pooling이라고 생각하면 됨
그다음에는 논문 3가지에 언급된 방법 이용(1개는 위 2개 중 하나와 겹침)
각 view가 - 다른 view의 target $z_j^\xi$에 대한 예측 $q_\theta(z_i^\theta)$ 형성
이는 동일한 achitecture 와 더 천천히 변하는 가중치 $\xi$ 집합으로 계산된다는데 appendix C.2를 보자
이를 통한 standard contrastive loss:
$$ \mathcal L_\text{SSL}^{ij}(\theta;\xi) = -\log{\exp(q_\theta(z_i^\theta)\cdot z_j^\xi) \over \exp(q_\theta(z_i^\theta) \cdot z_i^\xi) + \sum_k \exp(q_\theta(z_i^\theta) \cdot z_k^\xi)} $$
뒷부분은 이제 정리 느낌인데 이전 논문 2개 와 loss 도출 과정에 필요한 논문 4개 정리 후에 appendix내용과 함꼐 추가 보강 하겠음!