figure-convolutional-attention-network.tex 6.15 KB
Newer Older
1 2
\begin{tikzpicture}

单韦乔 committed
3
\tikzstyle{elementnode} = [anchor=center,draw=gray,minimum size=0.6em,inner sep=0.1pt]
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

\begin{scope}[scale=1.0]
\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
    \node[elementnode] (a\i\j) at (0.6em*\i,0.6em*\j) {};

\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
单韦乔 committed
20
    \node[elementnode,fill=orange!15] (b\i\j) at (0.6em*\i+5.5em,0.6em*\j) {};
21 22 23 24 25 26 27 28 29 30 31 32


\node [anchor=south west,minimum height=0.5em,minimum width=4.8em,inner sep=0.1pt,very thick,blue!60,draw] (n1) at ([xshift=0em,yshift=0em]a01.south west) {};
\node [anchor=north west,minimum height=0.5em,minimum width=4.8em,inner sep=0.1pt,very thick,red!60,draw] (n2) at ([xshift=0em,yshift=0em]a02.north west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,blue!60,draw] (n3) at ([xshift=0em,yshift=0em]b21.west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,red!60,draw] (n4) at ([xshift=0em,yshift=0em]b42.west) {};

\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.south east) -- ([xshift=0em,yshift=0em]n3.south west);
\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.north east) -- ([xshift=0em,yshift=0em]n3.north west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.south east) -- ([xshift=0em,yshift=0em]n4.south west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.north east) -- ([xshift=0em,yshift=0em]n4.north west);

xiaotong committed
33
\node [anchor=north] (l1) at ([xshift=0.5em,yshift=-1em]a70.south){\footnotesize {(a)标准自注意力模型}};
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
\node [anchor=south,rotate=90] (l2) at ([xshift=0em,yshift=0em]a02.west){\scriptsize {注意力头}};
\node [anchor=south] (l2) at ([xshift=0em,yshift=0em]a44.north){\scriptsize {句子长度}};

\end{scope}

\begin{scope}[scale=1.0,xshift=4.6cm]
\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
    \node[elementnode] (a\i\j) at (0.6em*\i,0.6em*\j) {};

\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
单韦乔 committed
54
    \node[elementnode,fill=orange!15] (b\i\j) at (0.6em*\i+5.5em,0.6em*\j) {};
55 56 57 58 59 60 61 62 63 64 65 66


\node [anchor=south west,minimum height=0.5em,minimum width=3em,inner sep=0.1pt,very thick,blue!60,draw] (n1) at ([xshift=0em,yshift=0em]a01.south west) {};
\node [anchor=north west,minimum height=0.5em,minimum width=3em,inner sep=0.1pt,very thick,red!60,draw] (n2) at ([xshift=0em,yshift=0em]a22.north west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,blue!60,draw] (n3) at ([xshift=0em,yshift=0em]b21.west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,red!60,draw] (n4) at ([xshift=0em,yshift=0em]b42.west) {};

\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.south east) -- ([xshift=0em,yshift=0em]n3.south west);
\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.north east) -- ([xshift=0em,yshift=0em]n3.north west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.south east) -- ([xshift=0em,yshift=0em]n4.south west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.north east) -- ([xshift=0em,yshift=0em]n4.north west);

xiaotong committed
67
\node [anchor=north] (l1) at ([xshift=0.5em,yshift=-1em]a70.south){\footnotesize {(b)一维卷积注意力模型}};
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
\node [anchor=south,rotate=90] (l2) at ([xshift=0em,yshift=0em]a02.west){\scriptsize {注意力头}};
\node [anchor=south] (l2) at ([xshift=0em,yshift=0em]a44.north){\scriptsize {句子长度}};

\end{scope}

\begin{scope}[scale=1.0,xshift=9.2cm]
\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
    \node[elementnode] (a\i\j) at (0.6em*\i,0.6em*\j) {};

\foreach \i / \j in
    {0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4,
    0/3, 1/3, 2/3, 3/3, 4/3, 5/3, 6/3, 7/3,
    0/2, 1/2, 2/2, 3/2, 4/2, 5/2, 6/2, 7/2,
    0/1, 1/1, 2/1, 3/1, 4/1, 5/1, 6/1, 7/1,
    0/0, 1/0, 2/0, 3/0, 4/0, 5/0, 6/0, 7/0}
单韦乔 committed
88
    \node[elementnode,fill=orange!15] (b\i\j) at (0.6em*\i+5.5em,0.6em*\j) {};
89 90 91 92 93 94 95 96 97 98 99 100


\node [anchor=south west,minimum height=1.8em,minimum width=3em,inner sep=0.1pt,very thick,blue!60,draw] (n1) at ([xshift=0em,yshift=0em]a00.south west) {};
\node [anchor=north west,minimum height=1.8em,minimum width=3em,inner sep=0.1pt,very thick,red!60,draw] (n2) at ([xshift=0em,yshift=0em]a23.north west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,blue!60,draw] (n3) at ([xshift=0em,yshift=0em]b21.west) {};
\node [anchor=west,minimum height=0.6em,minimum width=0.6em,inner sep=0.1pt,very thick,red!60,draw] (n4) at ([xshift=0em,yshift=0em]b42.west) {};

\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.south east) -- ([xshift=0em,yshift=0em]n3.south west);
\draw [-,very thick,dotted,blue!60] ([xshift=0em,yshift=0em]n1.north east) -- ([xshift=0em,yshift=0em]n3.north west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.south east) -- ([xshift=0em,yshift=0em]n4.south west);
\draw [-,very thick,dotted,red!60] ([xshift=0em,yshift=0em]n2.north east) -- ([xshift=0em,yshift=0em]n4.north west);

xiaotong committed
101
\node [anchor=north] (l1) at ([xshift=0.5em,yshift=-1em]a70.south){\footnotesize {(c)二维卷积注意力模型}};
102 103 104 105 106
\node [anchor=south,rotate=90] (l2) at ([xshift=0em,yshift=0em]a02.west){\scriptsize {注意力头}};
\node [anchor=south] (l2) at ([xshift=0em,yshift=0em]a44.north){\scriptsize {句子长度}};

\end{scope}
\end{tikzpicture}