DN-DETR阅读笔记
(一) Title
论文地址:https://arxiv.org/pdf/2203.01305
代码地址:https://github.com/IDEA-opensource/DN-DETR
官方解读:https://zhuanlan.zhihu.com/p/478079763
(二) Summary
(三) Problem Statement
(四) Methods
详细的工作情况为:
使用
A
=
[
a
i
j
]
W
×
W
\mathbf{A}=\left[\mathbf{a}_{i j}\right]_{W \times W}
A=[aij]W×W来表示attention mask,其中
W
=
P
×
M
+
N
W=P \times M+N
W=P×M+N.
P
P
P和
M
M
M分别表示group数量以及真实边界框的数量,
N
N
N表示matching 部分的queries数量,也就是
P
×
M
P \times M
P×M表示denoising part,后面的
N
N
N表示matching part.其中
a
i
j
=
1
a_{ij}=1
aij=1表示第
i
i
i个query看不到第
j
j
j个query,这个
A
\mathbf{A}
A就是注意力矩阵,如下所示:
a
i
j
=
{
1
,
if
j
<
P
×
M
and
⌊
i
M
⌋
≠
⌊
j
M
⌋
1
,
if
j
<
P
×
M
and
i
≥
P
×
M
0
,
otherwise
a_{i j}=\left\{\begin{array}{ll} 1, & \text { if } j<P \times M \text { and }\left\lfloor\frac{i}{M}\right\rfloor \neq\left\lfloor\frac{j}{M}\right\rfloor \\ 1, & \text { if } j<P \times M \text { and } i \geq P \times M \\ 0, & \text { otherwise } \end{array}\right.
aij=⎩⎨⎧1,1,0, if j<P×M and ⌊Mi⌋=⌊Mj⌋ if j<P×M and i≥P×M otherwise
需要注意的是这个
A
\mathbf{A}
A的形状,假设P=3,M=2,N=4,则A矩阵如下所示:
[
0
0
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
0
0
0
0
]
\begin{bmatrix} &0 &0 &1 &1 &1 &1 &0 &0 &0 &0\\ &0 &0 &1 &1 &1 &1 &0 &0 &0 &0\\ &1 &1 &0 &0 &1 &1 &0 &0 &0 &0\\ &1 &1 &0 &0 &1 &1 &0 &0 &0 &0\\ &1 &1 &1 &1 &0 &0 &0 &0 &0 &0\\ &1 &1 &1 &1 &0 &0 &0 &0 &0 &0\\ &1 &1 &1 &1 &1 &1 &0 &0 &0 &0\\ &1 &1 &1 &1 &1 &1 &0 &0 &0 &0\\ &1 &1 &1 &1 &1 &1 &0 &0 &0 &0\\ &1 &1 &1 &1 &1 &1 &0 &0 &0 &0 \end{bmatrix}
⎣⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎡0011111111001111111111001111111100111111111100111111110011110000000000000000000000000000000000000000⎦⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎤
A
\mathbf{A}
A矩阵不是对称矩阵,文中指出允许denoising part来see matching part,不过从矩阵中看到的是预训matching part来see denoising part(这里可能是原文中表述出现问题).而且为什么这样做,也不是很明白。
Attention Mask的计算复杂度比较低.