\begin{tikzpicture} \setlength{\base}{1cm} \tikzstyle{rnnnode} = [rounded corners=1pt,minimum size=0.5\base,draw,inner sep=0pt,outer sep=0pt] \tikzstyle{wordnode} = [font=\footnotesize] % RNN translation model \begin{scope}[local bounding box=RNNMT] % RNN Encoder \coordinate (eemb0) at (0,0); \foreach \x [count=\y from 0] in {1,2,...,4} \node[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west] (eemb\x) at ([xshift=0.4\base]eemb\y.east) {}; \foreach \x in {1,2,...,4} \node[rnnnode,fill=blue!30!white,anchor=south] (enc\x) at ([yshift=0.5\base]eemb\x.north) {}; \node[wordnode,left=0.4\base of enc1,font=\footnotesize] (init) {0}; \node[wordnode,anchor=east] (init2) at ([xshift=-3.0em]init.west){}; { \node[rnnnode,fill=purple] (repr) at (enc4) {}; \node[wordnode] (label) at ([yshift=2.5em]enc4.north) { \begin{tabular}{c} 源语言句\\子表示 \end{tabular} }; \draw[->,dashed,thick] (label.south) -- (enc4.north); } \node[wordnode,below=0pt of eemb1,font=\footnotesize] (encwordin1) {我}; \node[wordnode,below=0pt of eemb2,font=\footnotesize] (encwordin2) {很}; \node[wordnode,below=0pt of eemb3,font=\footnotesize] (encwordin3) {好}; \node[wordnode,below=0pt of eemb4,font=\footnotesize] (encwordin4) {$\langle$eos$\rangle$}; %大括号 \draw[decorate,thick,decoration={mirror,brace}]([xshift=0.0em,yshift=-1.5em]eemb1.south west) --([xshift=0.0em,yshift=-1.5em]eemb4.south east) node [font=\footnotesize,xshift=-3.8em,yshift=-1.0em,align=center](label2) {编码器}; % RNN Decoder \foreach \x in {1,2,...,4} \node[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=south] (demb\x) at ([xshift=9.5em,yshift=-3.9em]enc\x.north) {}; \foreach \x in {1,2,...,4} \node[rnnnode,fill=blue!30!white,anchor=south] (dec\x) at ([yshift=0.5\base]demb\x.north) {}; \foreach \x in {1,2,...,4} \node[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=south] (softmax\x) at ([yshift=0.5\base]dec\x.north) {}; % Decoder input words \node[wordnode,below=0pt of demb1,font=\footnotesize] (decwordin) {$\langle$sos$\rangle$}; \ExtractX{$(demb2.south)$} \ExtractY{$(decwordin.base)$} \node[wordnode,anchor=base,font=\footnotesize] () at (\XCoord,\YCoord) {I}; \ExtractX{$(demb3.south)$} \ExtractY{$(decwordin.base)$} \node[wordnode,anchor=base,font=\footnotesize] () at (\XCoord,\YCoord) {am}; \ExtractX{$(demb4.south)$} \ExtractY{$(decwordin.base)$} \node[wordnode,anchor=base,font=\footnotesize] () at (\XCoord,\YCoord) {fine}; % Decoder output words \node[wordnode,above=0pt of softmax1,font=\footnotesize] (decwordout1) {I}; \ExtractX{$(softmax2.north)$} \ExtractY{$(decwordout1.base)$} \node[wordnode,anchor=base,font=\footnotesize] (decwordout2) at (\XCoord,\YCoord) {am}; \ExtractX{$(softmax3.north)$} \ExtractY{$(decwordout1.base)$} \node[wordnode,anchor=base,font=\footnotesize] (decwordout3) at (\XCoord,\YCoord) {fine}; \ExtractX{$(softmax4.north)$} \ExtractY{$(decwordout1.base)$} \node[wordnode,anchor=base,font=\footnotesize] (decwordout4) at (\XCoord,\YCoord) {$\langle$eos$\rangle$}; %大括号 \draw[decorate,thick,decoration={brace}]([xshift=0.0em,yshift=1.3em]softmax1.north west) --([xshift=0.0em,yshift=1.3em]softmax4.north east) node [font=\footnotesize,xshift=-3.8em,yshift=1.0em,align=center](label1) {解码器}; % Connections \draw[-latex'] (init.east) to (enc1.west); \foreach \x in {1,2,...,4} \draw[-latex'] (eemb\x) to (enc\x); \foreach \x in {1,2,...,4} \draw[-latex'] (demb\x) to (dec\x); \foreach \x in {1,2,...,4} \draw[-latex'] (dec\x.north) to ([yshift=0.5\base]dec\x.north); \foreach \x [count=\y from 2] in {1,2,...,3} { \draw[-latex'] (enc\x.east) to (enc\y.west); \draw[-latex'] (dec\x.east) to (dec\y.west); } \coordinate (bridge) at ([yshift=-1.15\base]demb2); \draw[-latex'] (enc4.east) -- (dec1.west); \node[] at ([xshift=1.5cm]dec4.east){}; \end{scope} \end{tikzpicture}