




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Adaptively Aligned Image Captioning via Adaptive Attention Time Lun Huang1Wenmin Wang1,3Yaxian Xia1Jie Chen1,2 1School of Electronic and Computer Engineering, Peking University 2Peng Cheng Laboratory 3Macau University of Science and Technology huanglun, wangwm, .mo xiayaxian, chenj Abstract Recent neural models for image captioning usually employ an encoder-decoder framework with an attention mechanism. However, the attention mechanism in such a framework aligns one single (attended) image feature vector to one caption word, assuming one-to-one mapping from source image regions and target caption words, which is never possible. In this paper, we propose a novel attention model, namely Adaptive Attention Time (AAT), to align the source and the target adaptively for image captioning. AAT allows the framework to learn how many attention steps to take to output a caption word at each decoding step. With AAT, an image region can be mapped to an arbitrary number of caption words while a caption word can also attend to an arbitrary number of image regions. AAT is deterministic and differentiable, and doesnt introduce any noise to the parameter gradients. In this paper, we empirically show that AAT improves over state-of-the-art methods on the task of image captioning. Code is available at 1Introduction Image captioning aims to automatically describe the content of an image using natural language 13, 29,16,6. It is regarded as a kind of “translation” task that translates the content in an image to a sequence of words in some language. Inspired by the development of neural machine translation 22, recent approaches to image captioning that adopt an encoder-decoder framework with an attention mechanism have achieved great success. In such a framework, a CNN-based image encoder is used to extract feature vectors for a given image, while an RNN-based caption decoder to generate caption words recurrently. The attention mechanism selects one attended feature vector for each one decoding step. Despite the success that the existing approaches have achieved, there are still limitations in the encoder-decoder framework. The attention model generates one single image feature vector at each decoding step, which subsequently provides the decoder information for making the prediction about a caption word. Obviously, one-to-one mapping from image regions to caption words is assumed in the paradigm, which, however, is never possible and may involve the following issues: 1) unnecessary or even misleading visual information is forcibly given to all caption words, no matter whether they require visual clues or not 15; 2) visual information in the decoder accumulates over time; however, words at earlier decoding steps require more knowledge about the image, but they are actually provided less; 3) its hard to understand interactions between objects by analyzing one single Corresponding author 33rd Conference on Neural Information Processing Systems (NeurIPS 2019), Vancouver, Canada. attended weighted averaged feature vector. To conclude, a decoder requires a different number of attention steps in different situations, which is what one-to-one mapping cant provide. To this end, we develop a novel attention model, namely Adaptive Attention Time (AAT), to realize adaptive alignment from image regions to caption words. At each decoding step, depending on its confi dence, AAT decides whether to take an extra attention step, or directly output a caption word and move on to the next decoding step. If AAT does so, then at the subsequent attention step, AAT will take one more attended feature vector into the decoder, and again, AAT will make the decision. The attention process continues, until AAT is confi dent enough to output a word. With the techniques from Adaptive Computation Time (ACT) 8, we are able to make AAT deterministic and differentiable. Furthermore, we take advantage of the multi-head attention 23 to introduce fewer attention steps and make it easier to comprehend interactions among objects in an image. We evaluate the effectiveness of AAT by comparing it with a base attention model, which takes one attending step as one decoding step, and a recurrent attention model, which takes a fi xed number of attention steps for each decoding step. We show that those two models are special cases of AAT, and AAT is superior to them with empirical results. Experiments also show that the proposed AAT outperforms previously published image captioning models. And one single image captioning model can achieve a new state-of-the-art performance of 128.6 CIDEr-D 24 score on MS COCO dataset offl ine test split. 2Related Work Image Captioning.Early approaches to image captioning are rule/template-based 30, 21 which generate slotted caption templates and use the outputs of object detection, attribute prediction and scene recognition to fi ll in the slots. Recently, inspired by the great development of neural machine translation 22, neural-based encoder-decoder framework became the mainstream choice for image captioning. For instance, an end-to-end framework is proposed with a CNN encoding the image to feature vector and an LSTM decoding it to caption 25. Further in 27, the spatial attention mechanisms on CNN feature map is used to incorporate visual context and is implicitly conditioned on the text generated so far. In 19, reinforcement learning algorithms are designed to directly optimize the non-differentiable evaluation metrics (e.g., BLEU 17 and CIDEr 24). Later, 15 introduces an adaptive attention mechanism to decide when to activate the visual attention. More recently, semantic information such as objects, attributes and relationships are integrated to generate better descriptions 32, 2, 31, 28, 9. Adaptive Computation Time.Adaptive computation time (ACT) was proposed as an algorithm to allow recurrent neural networks to learn how many computational steps to take between receiving an input and emitting an output. Later, ACT is utilized to design neural networks of a dynamic number of layers or operations 26,5. In this paper, we implement our Adaptive Attention Time (AAT) model by using the techniques of ACT. 3Method Our image captioning model with Adaptive Attention Time (AAT) is developed upon the attention based encoder-decoder framework. In this section, we fi rst describe the framework in Section 3.1, then show how we implement AAT to realize adaptive alignment in Section 3.2. 3.1Model Framework Image Encoder.The encoder in the attentive encoder-decoder framework is to extract a set of image feature vectorsA = a1,a2,.,akof different image regions for the given image, wherek is the number of image regions. A typical choice is a pre-trained Faster-RCNN 18 model 2. Caption Decoder.A two-layer LSTM decoder is popular in recent researches for image caption- ing 2. We formalize a decoder with this kind of structure into three parts: an input module, an attention module and an output module. 2 , t n q , t na 2 LSTM 2 ,1t n h 2 , t n h Attend 1 t h Linear A , t n p Confidence , t n q , t na 2 LSTM 2 ,1t n h 2 , t n h Attend 1 t h Linear A 2 , R tt M ch ( ) 12 ,0, 1 N t tttt nt n n chh ta 2 LSTM 2 -1t h 2 t h Attend 1 t h A 2 tt ch (a) Attention Module: Base(b) Attention Module: Recurrent(c) Attention Module: Adaptive Figure 1: Different attention models. For each decoding step,(a)base takes one attention step; (b) recurrent takes a fi xed MRsteps; (c) adaptive takes adaptive steps. The input module, which models the input word as well as the context information of the decoder, consists of an LSTM layer (LSTM1). The process of this layer is: (h1 t,m 1 t) = LSTM1(tWe, a + ct1,(h 1 t1,m 1 t1) (1) whereh1 t,m1t are the hidden state and memory cell of LSTM1,Weis a word embedding matrix, andtis one-hot encoding of the input word at time stept,ct1is the previous context vector of the decoder, which is also the output of the attention module and input of the output module, and a = 1 k P iaiis the mean-pooling ofAand added toct1to provide global information to the input module. The attention module applies the proposed attention model on the image feature setAand generates a context vectorct, which is named as Adaptive Attention Time (AAT) and will be introduced in the following section together with other comparing attention models. The output module passesctthrough a linear layer with softmax activation to predict the probability distribution of the vocabulary: p(yt| y1:t1) = softmax(ctWp+ bp)(2) 3.2Adaptive Alignment via Adaptive Attention Time To implement adaptive alignment, we allow the decoder to take arbitrary attention steps for every decoding step. We fi rst introduce the base attention mechanism which takes one attention step for one decoding step, then the recurrent version which allows the decoder to take a fi xed number of attention steps, fi nally the adaptive version Adaptive Attention Time (AAT), which adaptively adjusts the attending time. 3.2.1Base Attention Model Common practice of applying attention mechanism to image captioning framework is to measure and normalize the attention scoreiof every candidate feature vectoraiwith the given query (i.e.h1 t), resulting in one single weighted averaged vector a t= PK i iaiover the whole feature vector setA. By applying an attention mechanism to the image captioning framework, we obtain the attended feature vector: a t= fatt(h1t,A) (3) Next attogether with h1 t is fed into another LSTM layer (LSTM2): (h2 t,m 2 t) = LSTM2 ? a t,h1t,(h2t1,m2t1) ? (4) We let the context vector to be the output hidden state ct= h2 t. 3.2.2Recurrent Attention Model Rather than limiting the attention module to accessing the feature vectors only once for one decoding step. We allow attending for multiple times with recurrent attention. 3 First, we need to make the attention output vary with attention time, and we construct the attention queryqt,nat attention time stepnof decoding time steptby transformingh1 t andh2 t,n1through a linear layer: qt,n= h1 t,h 2 t,n1Wq+ bq (5) whereh2 t,0= h 2 t1, andh 2 t,n1is the output of LSTM2at attention time stepn1of decoding time step t. Thenqt,nis fed to the attention module and obtain a t= fatt(qt,n,A), which is further fed to LSTM2: h2 t,n,m 2 t,n= LSTM2 ? at,n,h1 t,(h 2 t1,j,m 2 t1,j) ? (6) We seth2 t = h2 t,Mr,m2t = m2 t,Mr, whereh 2 t,Mr,m2t,Mr are the hidden state and memory cell of the last attention step and Mris the attention steps for each decoding step. We let the context vector to be the output hidden state at the last attention step ct= h2 t,Mr = h2 t. 3.2.3Adaptive Attention Time We further allow the decoder attending to the image for arbitrary times with Adaptive Attention Time. To determine how many times to perform attention, an extra confi dence network is added to the output of LSTM2 , since its used to predict probability distribution. We design the confi dence network as a two-layer feed forward translation: pt,n= ? ?max ?0,h1 tW1+ b1 ? W2+ b2?n = 0 ?max ?0,h2 t,nW1+ b1 ? W2+ b2?n 0 (7) and the total attention steps is determined by: N(t) = minn0: n0 Y n=0 (1 pt,n) 0 (10) andh1 t is added to show that we can obtain context directly from the input module without attending to image feature vectors. andc2 t1is to show that when deciding not to attend image feature, the memory cell should maintain the previous state and not be updated. Normalization.We normalize the hidden state and memory cell at each attention step:h2 t,n = LayerNormh(h2 t,n), and m2t,n= LayerNormm(m2t,n) We also normalize the weight of each attention step to make the sum of them to 1:t,n t,n PN(t) n=0 t,n . Time Cost Penalty.We add a “attention time” loss to the training loss in order to penalize the time cost for attention steps: La t = ?N(t) + N(t) X n=0 (n + 1)(1 pt,n)?(11) whereis a hyper-parameter,(n+1)(1pt,n)encouragespt,nto be larger so that the total attention steps can be reduced, andN(t)is added to indicate the attention time steps and doesnt contribute to the parameter gradients. 4 Minimum and Maximum Attention Steps.We can set a minimum attention stepMminto make the attention module takes at leastMminattention steps for each decoding step, by simply setting pt,n= 0 for 0 = n = Mmin 1. We can also set a maximum attention stepsMmaxto make sure the attention module takes at most Mmaxattention steps by modifying N(t): N(t) = minMmax,minn0: n0 Y n=0 (1 pt,n) ?(12) As can be seen, the process of AAT is deterministic and can be optimized directly. We let the context vector to be the weighted average over all hidden states at all attention steps ct= t,0h1 t + PN(t) n=1 t,nh2 t,n= h 2 t. 3.2.4Connections between Different Attention Models Base attention model is a special case of recurrent attention model whenMr= 1, and recurrent attention model is a special case of adaptive attention model when Mmax= Mmin= Mr. 4Experiments 4.1Dataset, Settings, and Metrics Dataset.We evaluate our proposed method on the popular MS COCO dataset 14. MS COCO dataset contains 123,287 images labeled with at least 5 captions, including 82,783 for training and 40,504 for validation. MS COCO also provides 40,775 images as the test set for online evaluation. We use the “Karpathy” data split 11 for the performance comparisons, where 5,000 images are used for validation, 5,000 images for testing, and the rest for training. Settings.We convert all sentences to lower case, drop the words that occur less than 5 times, and trim each caption to a maximum of 16 words, which results in a vocabulary of 10,369 words. Identical to 2, we employ Faster-RCNN 18 pre-trained on ImageNet and Visual Genome to extract bottom-up feature vectors of images. The dimension of the original vectors is 2048, and we project them to the dimension ofd = 1024, which is also the hidden size of the LSTM of the decoder and the size of word embedding. As for the training process, we train our model under cross-entropy loss for 20 epochs with a mini- batch size of 10, and ADAM 12 optimizer is used with a learning rate initialized with 1e-4 and annealed by 0.8 every 2 epochs. We increase the probability of feeding back a sample of the word posterior by 0.05 every 3 epochs 4. Then we use self-critical sequence training (SCST) 19 to optimize the CIDEr-D score with REINFORCE for another 20 epochs with an initial learning rate of 1e-5 and annealed by 0.5 when the CIDEr-D score on the validation split has not improved for some training steps. Metrics.We use different metrics, including BLEU 17, METEOR 20, ROUGE-L 7, CIDEr- D 24 and SPICE 1, to evaluate the proposed method and compare with others. All the metrics are computed with the publicly released code2. 4.2Ablative Studies Attention Time Steps (Attention Model).To show the effectiveness of adaptive alignment for image captioning, we compare the results of different attention models with different attention time steps, including base, which uses the conventional attentive encoder-decoder framework and forces to align one (attended) image region to one caption word; recurrent, which at each decoding step attends to a fi xed length of image regions recurrently; and adaptive, the proposed method in this paper, which attends to an adaptive length of image regions at each decoding step, allowing adaptive alignment from image regions to caption words. 2 5 Table 1: Ablative studies of attention time steps. We show the results of different attention models with different attention time steps, which are reported after the cross-entropy loss training stage and the self-critical loss training stage. We obtain the mean score and the standard deviation of a metric for a model by training it for 3 times, each with a different seed for random parameter initialization. Model Attention Time StepsCross-Entropy LossSelf-Critical Loss min.max.avg.METEORCIDEr-DSPICEMETEORCIDEr-DSPICE Base11127.58 0.03113.37 0.1520.76 0.0327.96 0.02123.76 0.4121.35 0.10 Recurrent 22227.66 0.06114.21 0.3520.84 0.0528.06 0.05124.22 0.2421.54 0.10 44427.79 0.01114.72 0.1720.93 0.0828.14 0.05124.96 0.3321.75 0.03 88827.75 0.05114.74 0.2320.93 0.0528.16 0.02124.85 0.3021.76 0.01 Adaptive042.55 0.0127.82 0.02115.12 0.3820.94 0.0728.25 0.05126.48 0.2221.84 0.05 Table 2: Tradeoff for time cost penalty. We show the average attention time steps as well as the performance with different values of. The results are reported by a single model after self-critical training stage. avg. stepsBLEU-1BLEU-2BLEU-3BLEU-4ROUGECIDEr-DMETEORSPICE 1e-10.3535.856.9118.727.220.5 1e-31.0380.064.349.737.858.0125.728.221.6 1e-42.5480.164.650.138.258.2126.728.321.9 1e-53.7780.064.650.038.258.2126.528.321.8 04.0080.064.550.138.258.2126.728.321.8 From Table 1, we observe that: 1) recurrent attention model (slightly) improves base attention model for all metrics, especially for those under self-critical loss training stage. 2) Focusing on the Cider-D score under self-critical loss, greatening the attention time steps for recurrent attention improves the performance. 3) adaptive attention model (AAT) further outperforms recurrent attention while requiring an average attention time steps of 2.2, which is quite small comparing to 4 and 8 attention time steps of the recurrent attention model. It shows that: fi rstly, incorporating more attention steps by adopting recurrent attention model helps to obtain better performance, however increasing the computation cost linearly with the number of the recurrent steps; secondly, adaptively aligning image feature vectors to caption words via Adaptive Attention Time requires less computation cost meanwhile leading to further better performance. This indicates Adaptive Attention Time to be a general solution to such sequence to se
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五年度环保型管桩生产与销售合作协议
- 2025版高压电缆买卖合同标准范本
- 2025版高空作业施工企业劳动合同规范范本
- 二零二五年度煤炭运输与购销合同中的质量检测标准
- 二零二五年度冰淇淋原料产地直供合同
- 二零二五年度户外运动装备买卖合同第三方担保协议范本
- 二零二五版月子中心婴儿早教及产后恢复服务合同
- 2025版房产抵押担保租赁合同范本
- 二零二五版酒店与茶业公司茶水供应合同
- 2025版煤炭进口与运输一体化合同
- 2024北京东城区高三(上)期末生物试题和答案
- 【MOOC】国际金融学-湖南大学 中国大学慕课MOOC答案
- 数据安全风险评估报告
- 细胞学科普讲座模板
- 区块链与数字货币法法律服务行业营销策略方案
- 装修施工项目投标书模板
- 江苏省苏州市工业园区2025届数学九年级第一学期开学统考试题【含答案】
- 吊篮作业人员安全技术交底
- 机械加工与装配作业指导书
- 2024年辽宁省第二届职业技能大赛(焊接赛项)理论参考试题库(含答案)
- 2024年风力发电机设计导则DG03偏航和俯仰轴承报告(英文版)-NREL
评论
0/150
提交评论