论文地址:Non-local Neural Networks
代码地址:https://github.com/facebookresearch/video-nonlocal-net
本文是CVPR2018的一篇poster,来自Facebook
传统的卷积都只是在局部进行操作,无法得到更多的上下文信息,因此本文根据传统的non-local means method提出了使用卷积的Non-local Neural Networks
传统的卷积如果想要得到long-range dependency,需要重复多次local操作,没有效率,也很困难,因此提出了non-local方法作为一种简单的方法是来得到long-range dependency,并且可以添加到多种卷积模块中
Non-local means [4] is a classical filtering algorithm that computes a weighted mean of all pixels in an image.
Long-range dependencies can be modeled by graphical models such as conditional random fields (CRF) [29, 28].
A selfattention module computes the response at a position in a sequence (e.g., a sentence) by attending to all positions and taking their weighted average in an embedding space.
non-local block
non-local operation的数学表达式:
f用来度量输出位置和周围其他位置的尺度,g是在位置j对于输入信号的表示(在本文中为卷积操作)
对于non-local behaiver来说,上式中的j是取遍所有可能的邻居,而对于local操作,如3*3的卷积来说,j只是取了周围8个像素点,如递归卷积来说,j只是取了前一个和后一个time
对于g来说,只考虑为,W为需要学习的参数,使用1*1卷积,或者1*1*1卷积来实施
主要讨论f,一种列了四种f
1、Gaussian
2、Embedded Gaussian.
3、Dot product.
4、Concatenation.
整个模块如上,X为输入,Z为输出,首先把X为T*H*W*1024copy为三份,分别进行三条路,以Embedded Gaussian为例进行介绍
1、 使用1*1*1卷积对X进行降维成T*H*W*512,然后进行reshape到THW*512,相当于进行操作
2、使用1*1*1卷积对X进行降维成T*H*W*512,然后进行reshape到512*THW,相当于进行操作
然后对1和2得到的结果进行矩阵相乘得到THW*THW的结果,相当于进行操作,然后进行softmax操作,相当于进行
3、使用1*1*1卷积对X进行降维成T*H*W*512,然后进行reshape到THW*512,相当于进行操作
然后把1和2进行矩阵相乘经过softmax的结果和3得到的结果进行矩阵相乘得到THW*512,相当于进行
最后使用1*1*1卷积将上一步得到的结果THW*512成为T*H*W*1024
然后这个结果和x相加,形成一个residual block
non-local block用于high-level, sub-sampled feature maps,T = 4, H = W = 14 or 7.
为了减少计算量,可以使用pooling对x进行采样操作
Video Classification Models
2D ConvNet baseline (C2D).
参考:https://blog.csdn.net/u014380165/article/details/80011785