figure-twodecoding.tex 3.18 KB
Newer Older
曹润柘 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
\tikzstyle{encoder} = [rectangle,thick,rounded corners,minimum width=2.3cm,minimum height=1.4cm,text centered,draw=black!70,fill=red!25]
\tikzstyle{decoder} = [rectangle,thick,rounded corners,minimum width=2.3cm,minimum height=1.4cm,text centered,draw=black!70,fill=blue!15]
\tikzstyle{attention} = [rectangle,thick,rounded corners,minimum width=2.6cm,minimum height=0.9cm,text centered,draw=black!70,fill=green!25]

\begin{tikzpicture}[node distance = 0,scale = 1]
\tikzstyle{every node}=[scale=1]
\node(encoder_left)[encoder]{\large{编码器}};
\node(encoder_right)[encoder, right of = encoder_left, xshift=3cm]{\large{编码器}};
\node(decoder_left)[decoder, above of = encoder_left, yshift=2.7cm]{\large{解码器}};
\node(decoder_right)[decoder, above of = encoder_right, yshift=2.7cm]{\large{解码器}};
\node(text_left)[below of = encoder_left, yshift=-2.2cm]{\large{前文}};
\node(text_right)[below of = encoder_right, yshift=-2.2cm]{\large{源语}};
\node(text_top)[above of = decoder_right, yshift=2cm]{\large{句子级翻译结果}};
\node(title_1)[above of = text_top, xshift=-1.5cm, yshift=1.3cm]{\large\bfnew{一阶段解码}};
\node(ground2)[rectangle,very thick,rounded corners,minimum width=5cm,minimum height=5.3cm,right of = encoder_right,xshift=6cm,yshift=1.4cm,draw=black,dashed]{};
\node(ground1)[rectangle,thick,rounded corners,minimum width=3.3cm,minimum height=4.5cm,right of = encoder_right,xshift=5.5cm,yshift=1.4cm,draw=black,fill=yellow!15]{};
\node(attention_below)[attention, right of = encoder_right, xshift=5.5cm]{\large{注意力机制}};
\node(attention_above)[attention, above of = attention_below, yshift=1.4cm]{\large{注意力机制}};
\node(ffn)[attention, above of = attention_above, yshift=1.4cm, fill=blue!8]{\large{前馈神经网络}};
\node(n)[right of = attention_above, xshift=2.4cm,scale=1.5]{$\times N$};
\node(text_2)[above of = ffn, yshift=1.9cm]{\large{上下文修正结果}};
\node(title_2)[above of = text_2, xshift=0.5cm,yshift=1.3cm]{\large\bfnew{二阶段解码}};
\node(text_rright)[right of = text_right, xshift=5.5cm]{\large{句子级翻译结果}};

\draw[->,very thick]([yshift=0.2cm]text_left.north)to(encoder_left.south);
\draw[->,very thick]([yshift=0.2cm]text_right.north)to(encoder_right.south);
\draw[->,very thick](encoder_left.north)to(decoder_left.south);
\draw[->,very thick](encoder_right.north)to(decoder_right.south);
\draw[->,very thick](decoder_right.north)to([yshift=-0.1cm]text_top.south);
\draw[->,very thick]([yshift=0.2cm]text_rright.north)to(attention_below.south);
\draw[->,very thick](attention_below.north)to(attention_above.south);
\draw[->,very thick](attention_above.north)to([yshift=-0.05cm]ffn.south);
\draw[->,very thick](ffn.north)to([yshift=-0.05cm]text_2.south);
\draw[-,very thick,dashed]([xshift=2cm,yshift=-0.2cm]text_right.east)to([xshift=2cm,yshift=9cm]text_right.east);
\draw[-,very thick]([yshift=0.5cm]encoder_left.north)--([yshift=0.5cm,xshift=4.5cm]encoder_left.north)--([xshift=-2.68cm]attention_below.west)--(attention_below.west);
\draw[-,very thick](decoder_left.north)--([yshift=0.5cm]decoder_left.north)--([yshift=0.5cm,xshift=4.7cm]decoder_left.north)--([xshift=-2.48cm]attention_above.west)--(attention_above.west);
\end{tikzpicture}