knowing when to look : adaptive attention via a visual sentinel for image captioning

18
Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning 참참참참 “Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning”, Jiasen Lu, Caiming Xiong, Devi Parikh, Richard Socher 2017. 1. 참참참 참참참참참참참참참

Upload: -

Post on 07-Feb-2017

360 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning

참고자료“Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning”, Jiasen Lu, Caiming Xiong, Devi Parikh, Richard Socher

2017. 1.

김홍배한국항공우주연구원

Page 2: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

Image Caption-ing 1 장의 스틸사진으로 부터 설명문 (Caption) 을 생성 자동번역등에 사용되는 Recurrent Neural Networks (RNN) 에

Deep Convolutional Neural Networks 에서 생성한 이미지의 특징벡터를 입력 Neural Image Caption (NIC)

Page 3: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

Example : Neural Image Caption (NIC)

Page 4: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

4

기존 기술과의 차이 일반적으로 생성된 각각의 단어와 연결된 이미지 영역의 공간지도를 만드는 Attention Mechanism 을 사용 따라서 시각신호의 중요성에 관련없이 Attention model 이 매번 각 이미지에 적용됨 이는 자원의 낭비뿐만 아니라 비시각적 단어 (a, of, on, and top, etc) 를 사용한 훈련은 설명문 생성에서 성능저하를 유발

본 연구에서는 Hidden layer 위에 추가적인 시각중지 벡터 (visual sentinel vector) 를 갖는 LSTM 의 확장형을 사용 . 시각신호로부터 필요시 언어모델로 전환이 가능한 Adaptive attention encoder-decoder framework 이모델은 “ white”, “bird”, “stop,” 과 같은 시각적 단어에 대해서는 좀 더 이미지에 집중하고 , “top”, “of”, “on.” 의 경우에는 시각중지를 사용

Page 5: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

5

기존 기술과의 차이Atten : 새로 추가된 모듈

vi : spatial image features St : visual sentinel vector

Page 6: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

6

Encoder-Decoder for Image Caption-ing 사진 (I) 를 입력으로 주었을 때 정답 “설명문“ , y 를 만들어 낼 가능성을 최대가 되도록 학습데이터 (I, y) 를 이용하여 넷의 변수 (ϴ) 들을 찾아내는 과정

설명문ϴ∗ = argmin

ϴ 사진 , 변수

확률

손실함수전체 학습데이터 셋에 대한 손실함수

손실함수를 최소화 시키는 변수 , ϴ* 를 구하는 작업

Page 7: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

7

log𝑝 (𝑦|𝐼 ;ϴ )=∑𝑡=0

𝑁

log𝑝 ( 𝑦𝑡|𝐼 , 𝑦 0 , 𝑦1 , · ·· , 𝑦𝑡 −1 ;ϴ )

학습 데이터 셋 (I,y) 로 부터 훈련을 통해 찾아내는 변수

log likelihood of the joint probability distribution

Encoder-Decoder for Image Caption-ing

Recurrent neural network (RNN) 을 사용한 encoder-decoder frame-work 에서는 개개 conditional probability 는 다음과 같이 정의

log𝑝 (𝑦 𝑡|𝐼 , 𝑦0 , 𝑦1 ,· · · , 𝑦𝑡− 1)= 𝑓 (h𝑡 ,𝑐𝑡 )

Page 8: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

8

log𝑝 (𝑦 𝑡|𝐼 , 𝑦0 , 𝑦1 ,· · · , 𝑦𝑡− 1)= 𝑓 (h𝑡 ,𝑐𝑡 )

Encoder-Decoder for Image Caption-ing

Visual context vector @ time tHidden state @ time t

확률을 출력하는 비선형 함수 (eg. Softmax)

: Long-Short Term Memory (LSTM) 인 경우

= LSTM(; ;

memory cell vector at time t-1

Page 9: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

9

Encoder-Decoder for Image Caption-ingSpatial Attention Model

최종 목표인 Adaptive Attention Model 에 들어가기 전 Spatial Attention Model 에 대해 간단하게 알아봅시다 .

1. Vanilla encoder-decoder frameworks - 는 encoder 인 CNN 에만 의존

- 입력 이미지 , I 가 CNN 에 들어가서 마지막 FCL 에서 global image feature 를

뽑아냄 . - 단어생성과정에서 는 decoder 의 hidden state 에 상관없이 일정함

2. Attention based encoder-decoder frameworks - 는 encoder & decoder 모두에 의존

- 시간 t 에서 hidden state 의 상태에 따라 decoder 가 이미지의 특정 영역으로 부터의

spatial image features 를 이용하여 를 계산

context vector 를 계산할 때 , 다음과 같이 두개의 접근방법이 있음 .

Page 10: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

10

Encoder-Decoder for Image Caption-ing

= g(V;

context vector

attention function

, , ,

는 the spatial image features 는 LSTM 의 hidden state @ time t

구하는 방법은 뒤에 계산방법이 자세히 나옴

Spatial Attention Model

Page 11: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

11

Encoder-Decoder for Image Caption-ingSpatial Attention Model

우선 이미지상의 k 개의 영역에 대한 attention 분포 , 를 계산 =

=softmax (

,

context vector 음과 같이 정의

𝑐𝑡=∑𝑖=1

𝑘

𝛼 𝑡𝑖𝑣𝑡𝑖

Page 12: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

12

Adaptive Attention Model spatial attention 기반의 decoders 가 image captioning 에 효과적이긴 하나 , 시각적 신호와 언어모델 중 어느 쪽을 선택하여야 하는지는 결정하지 못함 .

Visual sentinel gate( 시각중지 게이트 ), 라는 새로운 게이트를 도입

vi : spatial image features St : visual sentinel vector

Encoder-Decoder for Image Caption-ing

Page 13: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

13

를 이용하여 새로운 Adaptive context vector, 를 정의

vi : spatial image features St : visual sentinel vector

= +(1- 0 ~ 1 사이의 상수를 생성≈1 : 시각중지 정보만 사용 언어모델만 사용≈0 : 공간영상 정보만 사용 시각정보만 사용

Adaptive Attention ModelEncoder-Decoder for Image Caption-ing

Page 14: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

14

앞에서 언급한 이미지 상의 attention 분포 , 를 다음과 같이 수정=softmax (

visual sentinel vector에 대한 attention 분포를 나타냄 .

으로 정의 함 .

시간 t 에서 가능한 단어들의 어휘에 대한 선택 확률은 다음과 같이 계산=softmax (

Adaptive Attention ModelEncoder-Decoder for Image Caption-ing

Page 15: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

15

Image EncodingCNN 출력으로부터 image feature vector 구하기

• 이미지에 대한 Encoding 은 ResNet 의 마지막 convolutional layer

의 spatial feature 출력 (2,048x7x7) 을 사용• 이미지상의 k 개 영역의 CNN 의 spatial feature 와의 관계 (?)

Encoder-Decoder for Image Caption-ing

,

Global image feature, 다음과 같이 평균값으로 정의 𝑎𝑔=1

𝑘∑𝑖=1

𝑘

𝑎𝑖

Page 16: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

16

Image EncodingCNN 출력으로부터 image feature vector 구하기

Encoder-Decoder for Image Caption-ing

=ReLU (

로 부터 d 차원의 변환하기

=ReLU (

입력벡터 ,

= 는 “ word embedding vector”, lobal image feature vector”

Page 17: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

실험결과

Page 18: Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Captioning

실험결과