近年来,Attention机制在深度学习领域受到了越来越多的关注。从数学的形式上看,Attention机制只是简单地对输入项根据重要程度分配不同的加权参数,但这一机制模拟了人脑的认知模式,即根据实际需求而将有限的注意力聚焦于事物的关键部分,从而大大加强了神经网络的理解能力。
由于VQA涉及对图像和文字的深度理解,Attention机制在VQA领域自然成了一大利器。延续之前的研究工作Image caption(图像摘要),计算机只做了感知和抽取图片信息的工作,接下来计算机就可以利用从图片中得到的信息进行推理生成文本,并以问答的形式呈现,即视觉问答(VQA)任务。所以这周将attention机制在VQA中的典型应用梳理了一下,写一篇博客留下点痕迹。。。
Question-guided image attention
最早在VQA中应用attention的工作大概是这两个:
Xu等人的Ask, Attend and Answer: Exploring Question-Guided Spatial Attention for Visual Question Answering,发表于ECCV 2016。
![4d92ecad51a5053f13d98912f0cbe34b.png](https://i-blog.csdnimg.cn/blog_migrate/a9b63fb42668366b8fd7c1e7c3af0b16.png)
![92ec527cbed0e9bfe4ac26f02d714f85.png](https://i-blog.csdnimg.cn/blog_migrate/cc94b48ee8b99745916719aaefd599d2.jpeg)
Yang等人的Stacked Attention Networks for Image Question Answering,发表于同一年的CVPR。
![9e2189372b11b452eeaf9c75229639f6.png](https://i-blog.csdnimg.cn/blog_migrate/fbf416860aad225c012dee63fdf35db7.jpeg)
这两个工作整体思路上大同小异,其中的attention机制都属于question-guided image attention,根据问题调整对图片的注意力,从而使模型关注关键的区域。
Co-attention
上面的attention解决的是“看哪里”的问题,而实际上,对于VQA这种多模态问题,考虑“关注问题中的哪些单词”也同样重要,于是自然想到把question attention加入模型中。
在这方面,Lu等人在NIPS 2016上发表的Hierarchical Question-Image Co-Attention for Visual Question Answering是一个先驱工作。
![5e6f4c208ec5436af7c3128ac6fd2d75.png](https://i-blog.csdnimg.cn/blog_migrate/65381b1e30105e353aedbbe7d34e3246.jpeg)
这一工作考虑了image attention和question attention的协同作用,既有question-guided image attention,又有image-guided question attention,具有对称性,故称co-attention。
另外,本文的另一特色是利用了层级架构(hierarchy)。
Nam等人的Dual Attention Networks for Multimodal Reasoning and Matching(CVPR 2017)也应用了极其类似的attention机制:
![abb0428f0e0031db179e97e00ae28ec3.png](https://i-blog.csdnimg.cn/blog_migrate/1d8c8fc56aa387bc93b3e7b21c808ffa.png)
从模型示意图上可以看到,这里同样应用了image attention和question attention,两者通过共有的memory向量互相产生联系并通过迭代过程逐步细化。
另外,ICCV 2017上Yu等人的Multi-modal Factorized Bilinear Pooling with Co-Attention Learning for Visual Question Answering也用到这种co-attention。在他们的模型中,question attention参与image attention的计算,但不同上面两个工作,这里question attention是独立推断的,作者们认为这与人类的反应一致,人们不需要借助图片也能抓住问题的重点。
![00c7c4d08ac73e93fb5dcdafe158830c.png](https://i-blog.csdnimg.cn/blog_migrate/f1705e2b0ada5969f9e0ee74ef8737ea.jpeg)
Detection attention
CVPR 2018的oral论文Bottom-Up and Top-Down Attention for Image Captioning and Visual Question Answering因为其团队夺得了VQA Challenge 2017的冠军而名声大噪,其方法的新颖性在于提出了基于object detection的bottom-up attention。
此前的image attention都是基于CNN特征的,这相当于把图片均等分割成若干区域然后对其进行筛选;而本文提出的bottom-up attention则利用object detection网络Faster R-CNN来实现,将图片分割成一个个具体的物体来进行筛选。
![bc123cc1bf4222b7d7667962910826c2.png](https://i-blog.csdnimg.cn/blog_migrate/40e3f6aeed2770d6e7c29867e182dfe4.jpeg)
两者的对比图如上所示。基于CNN特征的attention由于缺乏对图片中具体物体的认知,所以可能仅仅关注物体的一部分,或关注到与问题无关的环境。相比之下,基于物体的attention更符合人类观察世界的习惯,因而显得更为自然。
![2c6b9dd501428d797b4a921a62abf5f8.png](https://i-blog.csdnimg.cn/blog_migrate/639c3ae8a4f92252a479290f96bd30dc.png)
上图是本文的模型示意图。值得注意的是,如文章标题所示,该模型应用了bottom-up和top-down attention。前者指的是Faster R-CNN筛选出一组最为明显的object,得到图中的Image features;后者在图中有示意,跟一般的image attention无异,表示对这些object给予不同程度的关注。
在同一年的AAAI上,Lu等人的Co-attending Free-form Regions and Detections with Multi-modal Multiplicative Feature Embedding for Visual Question Answering也用到了detection attention,但不同的是,他们并没有放弃原来那种基于CNN特征的image attention(他们称为free-form attention),而是将两者结合,形成free-form attention与detection attention的co-attention。
![a8a0ae96685dc37d72e3125606079652.png](https://i-blog.csdnimg.cn/blog_migrate/a256a7aae4984bc0edc76b12495246e8.jpeg)
detection attention的优势上面已经提到过了,然而,detection attention的作用受限于其检测类别的广度,如,对于“How is the weather today?”这样的问题,如果object detection网络不检测“天空”这个object,则模型无法对这一问题做出准确回答。而在这方面,free-form attention就显示出了优势,因此,本文认为这两种attention应是互补的。
Relational attention
以上的attention基本没有考虑图片中object之间的关系,而object之间的关系对于回答某些问题至关重要,如,在下面的例子中,模型需要比较两朵花的高度才能做出准确答复。
![e608ebc8750be6ab2084b6025b3273f7.png](https://i-blog.csdnimg.cn/blog_migrate/82e5f3fb97b8f8cbca69fe841aec97f7.jpeg)
基于此,ACM Multimedia 2018的一篇论文Object-Difference Attention: A Simple Relational Attention for Visual Question Answering提出了relational attention的概念,首先对图中object两两之间的关系进行建模,再用attention对这些关系进行筛选。
![da356911cc68f4c4fef0680861e8b64e.png](https://i-blog.csdnimg.cn/blog_migrate/1d9531dc5d01da40afca78691970bee4.jpeg)
这里简单地用差分操作来比较两个object特征,实际上,该论文还实验了其他操作,如加法、乘法等,最后发现还是减法最有效。然而,这些操作都显得过于简单了,因此,如何更合理地对object间的关系建模是一个可供改进的方向。