Memory Network系列4 - Improved Dynamic Memory Networks
-
References
- Dynamic Memory Networks for Visual and Textual Question Answering , 4 Mar 2016
- A Hierarchical Neural Autoencoder for Paragraphs and Documents , 6 Jun 2015
Improved Dynamic Memory Networks
DMN+由[1]提出,为DMN的改进模型,相比于DMN,DMN+主要做了以下改动:
Input Module for Text QA
在之前的DMN中,模型使用了一个单向GRU提取句子特征,将word输入GRU中,在输入句尾标记后输出hidden state作为sentence的特征。DMN虽然在有supporting facts标记的bAbI-1k中表现良好,但在没有supporting facts标记的bAbI-10k中表现得不好。本文推断造成这种差异有两个主要原因:
- GRU只能捕捉到当前句子之前的依赖关系而捕捉不到之后的依赖。
- 将word-level的特征输入GRU中会导致句子间的间隔过远难以产生记忆交互。
DNM+使用了一个由两个部分组成的网络替换掉了原来的GRU,第一部分叫做sentence reader,将由word vector组成的一句话encode为sentence vector;第二部分叫做
Input Fusion Layer
,使用了一个双向GRU提取句子及句子间的依赖信息。Sentence Reader
Sentence reader可以使用各种encode方式,如GRU、LSTM,本文使用了[2]中提到的positional encoder。
Positional encoder将word vector根据其位置编码后相加得到最终的sentence vector
: 其中,
是element-wise product, 为 个元素构成的向量,其表示如下: 其中,d为embedding index,D为embedding size。
Input Fusion Layer
这部分使用了双向GRU,将前一层得到的sentence vector作为输入:
Input Module For VQA
对于visual question answering,DMN+也提出了一种input module,其包括3个部分: local region feature extraction, visual feature embedding, input fusion layer 。
Local Region Feature Extraction
本部分的目的是提取image特征,可以使用预训练的图像模型作为特征提取器,取最后pool层的前一层的feature作为输出。
例如:的图像输入,会得到 的输出,也就是 个region信息。 Visual Feature Embedding
本部分为一个简单的fc,将前面的各region embedding。
Input Fusion Layer
这部分也像Text一样使用了一个双向GRU。
Episodic Memory Module
这部分相较于DMN,对Attention Mechanism和Memory Update Mechanism均做了改动。
Memory Update Mechanism
对于内部记忆的更新,本文提到了两种方式,一种是与DMN相同的Attention Based GRU,另一种是Soft attention。
- Attention Based GRU
- Soft Attention
在DMN中,各层使用GRU联系:
而在DMN+中,Following the memory update component used in Sukhbaatar et al. (2015) and Peng et al. (2015) we experiment with using a ReLU layer for the memory update, calculating the new episode memory state by
Attention Mechanism
其中,
是 element-wise absolute。
Performance
Text QA
VQA