Commit 21290ba3 by 曹润柘

合并分支 'caorunzhe' 到 'master'

Caorunzhe

查看合并请求 !929
parents c6a31115 4409c3f7
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
\node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em,minimum width=0em,rounded corners=5pt,thick] (n2) at ([xshift=3.5em,yshift=-0.5em]n1.east) {$\mathbi{X}$}; \node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em,minimum width=0em,rounded corners=5pt,thick] (n2) at ([xshift=3.5em,yshift=-0.5em]n1.east) {$\mathbi{X}$};
\node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!20,rounded corners=5pt,thick] (n3) at ([xshift=3.5em,yshift=0em]n2.east) {$\mathbi{x}_1$}; \node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!30,rounded corners=5pt,thick] (n3) at ([xshift=3.5em,yshift=0em]n2.east) {$\mathbi{x}_1$};
\node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!20,rounded corners=5pt,thick] (n4) at ([xshift=3.5em,yshift=0em]n3.east) {$\mathbi{x}_2$}; \node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!30,rounded corners=5pt,thick] (n4) at ([xshift=3.5em,yshift=0em]n3.east) {$\mathbi{x}_2$};
\node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em,minimum width=1em,rounded corners=5pt,thick] (n6) at ([xshift=1.5em,yshift=0em]n4.east) {$\ldots$}; \node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em,minimum width=1em,rounded corners=5pt,thick] (n6) at ([xshift=1.5em,yshift=0em]n4.east) {$\ldots$};
\node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!20,rounded corners=5pt,thick] (n5) at ([xshift=3.5em,yshift=0em]n6.east) {$\mathbi{x}_l$}; \node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!30,rounded corners=5pt,thick] (n5) at ([xshift=3.5em,yshift=0em]n6.east) {$\mathbi{x}_l$};
\node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!20,rounded corners=5pt,thick] (n7) at ([xshift=1.5em,yshift=0em]n5.east) {$\mathbi{x}_{l+1}$}; \node [anchor=west,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=3em,fill=orange!30,rounded corners=5pt,thick] (n7) at ([xshift=1.5em,yshift=0em]n5.east) {$\mathbi{x}_{l+1}$};
\node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=teal!17,rounded corners=5pt,thick] (n8) at ([xshift=0em,yshift=-3em]n4.south) {层正则化}; \node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=teal!30,rounded corners=5pt,thick] (n8) at ([xshift=0em,yshift=-3em]n4.south) {层正则化};
\node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=purple!17,rounded corners=5pt,thick] (n9) at ([xshift=0em,yshift=-1em]n8.south) {$\mathbi{X}\ \quad \mathbi{h}^1\ \quad \mathbi{h}^2\quad \ldots \quad\ \mathbi{h}^l$}; \node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=purple!30,rounded corners=5pt,thick] (n9) at ([xshift=0em,yshift=-1em]n8.south) {$\mathbi{X}\ \quad \mathbi{h}^1\ \quad \mathbi{h}^2\quad \ldots \quad\ \mathbi{h}^l$};
\node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=teal!17,rounded corners=5pt,thick] (n10) at ([xshift=0em,yshift=-2em]n9.south) {权重累加}; \node [anchor=north,rectangle,draw, inner sep=0mm,minimum height=1.2em,minimum width=15em,fill=teal!30,rounded corners=5pt,thick] (n10) at ([xshift=0em,yshift=-2em]n9.south) {权重累加};
\node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em, rounded corners=5pt,thick] (n11) at ([xshift=0em,yshift=-4.5em]n1.west) {聚合网络}; \node [anchor=west,rectangle, inner sep=0mm,minimum height=1.2em, rounded corners=5pt,thick] (n11) at ([xshift=0em,yshift=-4.5em]n1.west) {聚合网络};
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=green!20] \tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=green!30,draw,thick]
\tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=red!20] \tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=red!30,draw,thick]
\tikzstyle{fnoder}=[rectangle,inner sep=0mm,minimum height=2.4em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,red!40] \tikzstyle{fnoder}=[rectangle,inner sep=0em,minimum height=2.6em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,red!50]
\tikzstyle{fnodeg}=[rectangle,inner sep=0mm,minimum height=2.4em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,green!40] \tikzstyle{fnodeg}=[rectangle,inner sep=0em,minimum height=2.6em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,green!50]
\node [anchor=south west,fnodeg] (f1) at (0,0) {}; \node [anchor=south west,fnodeg] (f1) at (0,0) {};
\node [anchor=west,hnode] (n1) at ([xshift=0.2em,yshift=0em]f1.west) {$\mathbi{h}_1^{\textrm{up}}$}; \node [anchor=west,hnode] (n1) at ([xshift=0.2em,yshift=0em]f1.west) {$\mathbi{h}_1^{\textrm{up}}$};
......
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{unit}=[draw,rounded corners=2pt,drop shadow,font=\tiny] \tikzstyle{unit}=[draw,rounded corners=2pt,drop shadow,font=\tiny,thick]
%left %left
\begin{scope} \begin{scope}
\foreach \x/\d in {1/2em, 2/8em} \foreach \x/\d in {1/2em, 2/8em}
\node[unit,fill=yellow!20] at (0,\d) (ln_\x) {层正则化}; \node[unit,fill=yellow!30] at (0,\d) (ln_\x) {层正则化};
\foreach \x/\d in {1/4em} \foreach \x/\d in {1/4em}
\node[unit,fill=green!20] at (0,\d) (sa_\x) {8头自注意力:512}; \node[unit,fill=green!30] at (0,\d) (sa_\x) {8头自注意力:512};
\foreach \x/\d in {1/6em, 2/16em} \foreach \x/\d in {1/6em, 2/16em}
\node[draw,circle,minimum size=1em,inner sep=1pt] at (0,\d) (add_\x) {\scriptsize\bfnew{+}}; \node[draw,circle,minimum size=1em,inner sep=1pt] at (0,\d) (add_\x) {\scriptsize\bfnew{+}};
\foreach \x/\d in {2/14em} \foreach \x/\d in {2/14em}
\node[unit,fill=red!20] at (0,\d) (conv_\x) {卷积$1 \times 1$:512}; \node[unit,fill=red!30] at (0,\d) (conv_\x) {卷积$1 \times 1$:512};
\foreach \x/\d in {1/10em} \foreach \x/\d in {1/10em}
\node[unit,fill=red!20] at (0,\d) (conv_\x) {卷积$1 \times 1$:2048}; \node[unit,fill=red!30] at (0,\d) (conv_\x) {卷积$1 \times 1$:2048};
\foreach \x/\d in {1/12em} \foreach \x/\d in {1/12em}
\node[unit,fill=blue!20] at (0,\d) (relu_\x) {RELU}; \node[unit,fill=blue!30] at (0,\d) (relu_\x) {RELU};
\draw[->,thick] ([yshift=-1.4em]ln_1.-90) -- ([yshift=-0.1em]ln_1.-90); \draw[->,thick] ([yshift=-1.4em]ln_1.-90) -- ([yshift=-0.1em]ln_1.-90);
\draw[->,thick] ([yshift=0.1em]ln_1.90) -- ([yshift=-0.1em]sa_1.-90); \draw[->,thick] ([yshift=0.1em]ln_1.90) -- ([yshift=-0.1em]sa_1.-90);
...@@ -44,17 +44,17 @@ ...@@ -44,17 +44,17 @@
\foreach \x/\d in {1/2em, 2/8em, 3/16em} \foreach \x/\d in {1/2em, 2/8em, 3/16em}
\node[unit,fill=yellow!20] at (0,\d) (ln_\x) {层正则化}; \node[unit,fill=yellow!30] at (0,\d) (ln_\x) {层正则化};
\foreach \x/\d in {1/6em, 2/14em, 3/20em} \foreach \x/\d in {1/6em, 2/14em, 3/20em}
\node[draw,circle,minimum size=1em,inner sep=1pt] at (0,\d) (add_\x) {\scriptsize\bfnew{+}}; \node[draw,circle,minimum size=1em,inner sep=1pt] at (0,\d) (add_\x) {\scriptsize\bfnew{+}};
\node[unit,fill=red!20] at (0,4em) (glu_1) {门控线性单元:512}; \node[unit,fill=red!30] at (0,4em) (glu_1) {门控线性单元:512};
\node[unit,fill=red!20] at (-3em,10em) (conv_1) {卷积$1 \times 1$:2048}; \node[unit,fill=red!30] at (-3em,10em) (conv_1) {卷积$1 \times 1$:2048};
\node[unit,fill=cyan!20] at (3em,10em) (conv_2) {卷积$3 \times 1$:256}; \node[unit,fill=cyan!30] at (3em,10em) (conv_2) {卷积$3 \times 1$:256};
\node[unit,fill=blue!20] at (-3em,12em) (relu_1) {RELU}; \node[unit,fill=blue!30] at (-3em,12em) (relu_1) {RELU};
\node[unit,fill=blue!20] at (3em,12em) (relu_2) {RELU}; \node[unit,fill=blue!30] at (3em,12em) (relu_2) {RELU};
\node[unit,fill=cyan!20] at (0em,18em) (conv_3) {Sep卷积$9 \times 1$:256}; \node[unit,fill=cyan!30] at (0em,18em) (conv_3) {Sep卷积$9 \times 1$:256};
\draw[->,thick] ([yshift=-1.4em]ln_1.-90) -- ([yshift=-0.1em]ln_1.-90); \draw[->,thick] ([yshift=-1.4em]ln_1.-90) -- ([yshift=-0.1em]ln_1.-90);
...@@ -81,15 +81,15 @@ ...@@ -81,15 +81,15 @@
\node[font=\scriptsize,align=center] at (0em, -1.5em){(b) 使用结构搜索方法优化后的 \\ Transformer编码器中若干块的结构}; \node[font=\scriptsize,align=center] at (0em, -1.5em){(b) 使用结构搜索方法优化后的 \\ Transformer编码器中若干块的结构};
\node[minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=blue!20] (act) at (8em, 20em){}; \node[minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=blue!30] (act) at (8em, 20em){};
\node[anchor=west,font=\footnotesize] at ([xshift=0.1em]act.east){激活函数}; \node[anchor=west,font=\footnotesize] at ([xshift=0.1em]act.east){激活函数};
\node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=yellow!20] (nor) at ([yshift=-0.6em]act.south){}; \node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=yellow!30] (nor) at ([yshift=-0.6em]act.south){};
\node[anchor=west,font=\footnotesize] at ([xshift=0.1em]nor.east){层正则化}; \node[anchor=west,font=\footnotesize] at ([xshift=0.1em]nor.east){层正则化};
\node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=cyan!20] (wc) at ([yshift=-0.6em]nor.south){}; \node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=cyan!30] (wc) at ([yshift=-0.6em]nor.south){};
\node[anchor=west,font=\footnotesize] at ([xshift=0.1em]wc.east){宽卷积}; \node[anchor=west,font=\footnotesize] at ([xshift=0.1em]wc.east){宽卷积};
\node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=green!20] (at) at ([yshift=-0.6em]wc.south){}; \node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=green!30] (at) at ([yshift=-0.6em]wc.south){};
\node[anchor=west,font=\footnotesize] (tag) at ([xshift=0.1em]at.east){注意力机制}; \node[anchor=west,font=\footnotesize] (tag) at ([xshift=0.1em]at.east){注意力机制};
\node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=red!20] (nsl) at ([yshift=-0.6em]at.south){}; \node[anchor=north,minimum size=0.8em,inner sep=0pt,rounded corners=1pt,draw,fill=red!30] (nsl) at ([yshift=-0.6em]at.south){};
\node[anchor=west,font=\footnotesize] at ([xshift=0.1em]nsl.east){非空间层}; \node[anchor=west,font=\footnotesize] at ([xshift=0.1em]nsl.east){非空间层};
\begin{pgfonlayer}{background} \begin{pgfonlayer}{background}
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=green!30] \tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=green!30,draw,thick]
\tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=red!30] \tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=red!30,draw,thick]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.4em,minimum width=4.4em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.4em,minimum width=4.4em]
\node [anchor=south west,hnode] (n1) at (0,0) {$\mathbi{h}_1$}; \node [anchor=south west,hnode] (n1) at (0,0) {$\mathbi{h}_1$};
\node [anchor=west,hnode] (n2) at ([xshift=1em,yshift=0em]n1.east) {$\mathbi{h}_2$}; \node [anchor=west,hnode] (n2) at ([xshift=2em,yshift=0em]n1.east) {$\mathbi{h}_2$};
\node [anchor=west,hnode] (n3) at ([xshift=1em,yshift=0em]n2.east) {$\mathbi{h}_3$}; \node [anchor=west,hnode] (n3) at ([xshift=2em,yshift=0em]n2.east) {$\mathbi{h}_3$};
\node [anchor=west,hnode] (n4) at ([xshift=1em,yshift=0em]n3.east) {$\cdots$}; \node [anchor=west,hnode] (n4) at ([xshift=2em,yshift=0em]n3.east) {$\cdots$};
\node [anchor=west,hnode] (n5) at ([xshift=1em,yshift=0em]n4.east) {$\mathbi{h}_m$}; \node [anchor=west,hnode] (n5) at ([xshift=2em,yshift=0em]n4.east) {$\mathbi{h}_m$};
\node [anchor=south,tnode] (t1) at ([xshift=2.8em,yshift=1em]n1.north) {$\mathbi{h}_{m+1}$}; \node [anchor=south,tnode] (t1) at ([xshift=3.3em,yshift=1em]n1.north) {$\mathbi{h}_{m+1}$};
\node [anchor=south,tnode] (t2) at ([xshift=2.8em,yshift=1em]t1.north) {$\mathbi{h}_{m+2}$}; \node [anchor=south,tnode] (t2) at ([xshift=3.3em,yshift=1em]t1.north) {$\mathbi{h}_{m+2}$};
\node [anchor=south,tnode] (t3) at ([xshift=2.8em,yshift=1em]t2.north) {$\cdots$}; \node [anchor=south,tnode] (t3) at ([xshift=3.3em,yshift=1em]t2.north) {$\cdots$};
\node [anchor=south,tnode] (t4) at ([xshift=2.8em,yshift=1em]t3.north) {$\mathbi{h}_{2m-1}$}; \node [anchor=south,tnode] (t4) at ([xshift=3.3em,yshift=1em]t3.north) {$\mathbi{h}_{2m-1}$};
\draw [->,thick] ([xshift=0em,yshift=0em]n1.east) -- ([xshift=0em,yshift=0em]n2.west); \draw [->,thick] ([xshift=0em,yshift=0em]n1.east) -- ([xshift=0em,yshift=0em]n2.west);
\draw [->,thick] ([xshift=0em,yshift=0em]n2.east) -- ([xshift=0em,yshift=0em]n3.west); \draw [->,thick] ([xshift=0em,yshift=0em]n2.east) -- ([xshift=0em,yshift=0em]n3.west);
......
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{opnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4em,rounded corners=5pt,fill=teal!17] \tikzstyle{opnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4em,rounded corners=5pt,fill=teal!30]
\tikzstyle{cnode}=[circle,draw,minimum size=1.2em] \tikzstyle{cnode}=[circle,draw,minimum size=1.2em]
\tikzstyle{mnode}=[rectangle,inner sep=0mm,minimum height=5em,minimum width=11em,rounded corners=5pt,fill=yellow!20] \tikzstyle{mnode}=[rectangle,inner sep=0mm,minimum height=5em,minimum width=11em,rounded corners=5pt,fill=yellow!30]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.5em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.5em]
\begin{pgfonlayer}{background} \begin{pgfonlayer}{background}
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
\node[anchor=west,mnode] (m2) at ([xshift=1em,yshift=0em]m1.east){}; \node[anchor=west,mnode] (m2) at ([xshift=1em,yshift=0em]m1.east){};
\node[anchor=west,mnode] (m3) at ([xshift=1em,yshift=0em]m2.east){}; \node[anchor=west,mnode] (m3) at ([xshift=1em,yshift=0em]m2.east){};
\node[anchor=north west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=blue!20] (ml1) at ([xshift=0em,yshift=-0.5em]m1.south west){}; \node[anchor=north west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=blue!30] (ml1) at ([xshift=0em,yshift=-0.5em]m1.south west){};
\node[anchor=west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=ugreen!20] (ml2) at ([xshift=0.25em,yshift=0em]ml1.east){}; \node[anchor=west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=green!30] (ml2) at ([xshift=0.25em,yshift=0em]ml1.east){};
\node[anchor=north east,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=red!20] (ml3) at ([xshift=0em,yshift=-0.5em]m1.south east){}; \node[anchor=north east,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=3.5em,rounded corners=5pt,fill=red!30] (ml3) at ([xshift=0em,yshift=-0.5em]m1.south east){};
\node[anchor=north west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=5.25em,rounded corners=5pt,fill=blue!20] (mc1) at ([xshift=0em,yshift=-0.5em]m2.south west){}; \node[anchor=north west,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=5.25em,rounded corners=5pt,fill=blue!30] (mc1) at ([xshift=0em,yshift=-0.5em]m2.south west){};
\node[anchor=north east,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=5.25em,rounded corners=5pt,fill=red!20] (mc2) at ([xshift=0em,yshift=-0.5em]m2.south east){}; \node[anchor=north east,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=5.25em,rounded corners=5pt,fill=red!30] (mc2) at ([xshift=0em,yshift=-0.5em]m2.south east){};
\node[anchor=north,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=11em,rounded corners=5pt,fill=blue!20] (mr1) at ([xshift=0em,yshift=-0.5em]m3.south){}; \node[anchor=north,rectangle,inner sep=0mm,minimum height=2.6em,minimum width=11em,rounded corners=5pt,fill=blue!30] (mr1) at ([xshift=0em,yshift=-0.5em]m3.south){};
\end{pgfonlayer} \end{pgfonlayer}
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\tikzstyle{lnode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=3.5em,rounded corners=2pt,draw] \tikzstyle{lnode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=3em,rounded corners=2pt,draw,thick]
\tikzstyle{snode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=0.8em,rounded corners=2pt,draw] \tikzstyle{snode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=0.8em,rounded corners=2pt,draw,thick]
\tikzstyle{vlnode}=[rectangle,inner sep=0mm,minimum height=1em,minimum width=5em,rounded corners=2pt,draw] \tikzstyle{vlnode}=[rectangle,inner sep=0mm,minimum height=1em,minimum width=4em,rounded corners=2pt,draw,thick]
\node [anchor=west,lnode] (n1) at (0, 0) {$\mathbi{h}^3$}; \node [anchor=west,lnode] (n1) at (0, 0) {$\mathbi{h}^3$};
...@@ -13,53 +13,53 @@ ...@@ -13,53 +13,53 @@
\node [anchor=south] (d1) at ([xshift=0em,yshift=0.2em]n1.north) {1D}; \node [anchor=south] (d1) at ([xshift=0em,yshift=0.2em]n1.north) {1D};
\node [anchor=west,lnode] (n4) at ([xshift=1.2em,yshift=0em]n1.east) {}; \node [anchor=west,lnode] (n4) at ([xshift=1em,yshift=0em]n1.east) {};
\node [anchor=west,lnode] (n5) at ([xshift=1.2em,yshift=0em]n2.east) {}; \node [anchor=west,lnode] (n5) at ([xshift=1em,yshift=0em]n2.east) {};
\node [anchor=west,lnode] (n6) at ([xshift=1.2em,yshift=0em]n3.east) {}; \node [anchor=west,lnode] (n6) at ([xshift=1em,yshift=0em]n3.east) {};
\node [anchor=south,lnode] (n7) at ([xshift=0em,yshift=1em]n4.north) {$\mathbi{W}_1$}; \node [anchor=south,lnode] (n7) at ([xshift=0em,yshift=1em]n4.north) {$\mathbi{W}_1$};
\node [anchor=west] (sig) at ([xshift=0em,yshift=0.4em]n5.east) {$\sigma$}; \node [anchor=west] (sig) at ([xshift=0em,yshift=0.4em]n5.east) {$\sigma$};
\node [anchor=west,snode,fill=purple!30] (nc11) at ([xshift=1.2em,yshift=0em]n4.east) {}; \node [anchor=west,snode,fill=purple!30] (nc11) at ([xshift=1.2em,yshift=0em]n4.east) {};
\node [anchor=west,snode,fill=yellow!30] (nc12) at ([xshift=0em,yshift=0em]nc11.east) {}; \node [anchor=west,snode,fill=yellow!30] (nc12) at ([xshift=-0.06em,yshift=0em]nc11.east) {};
\node [anchor=west,snode,fill=red!30] (nc13) at ([xshift=0em,yshift=0em]nc12.east) {}; \node [anchor=west,snode,fill=red!30] (nc13) at ([xshift=-0.06em,yshift=0em]nc12.east) {};
\node [anchor=west,snode,fill=blue!30] (nc14) at ([xshift=0em,yshift=0em]nc13.east) {}; \node [anchor=west,snode,fill=blue!30] (nc14) at ([xshift=-0.06em,yshift=0em]nc13.east) {};
\node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc15) at ([xshift=0em,yshift=0em]nc14.east) {$\mathbi{o}_5^3$}; \node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc15) at ([xshift=-0.06em,yshift=0em]nc14.east) {$\mathbi{o}_5^3$};
\node [anchor=west,snode,fill=purple!30] (nc21) at ([xshift=1.2em,yshift=0em]n5.east) {}; \node [anchor=west,snode,fill=purple!30] (nc21) at ([xshift=1.2em,yshift=0em]n5.east) {};
\node [anchor=west,snode,fill=yellow!30] (nc22) at ([xshift=0em,yshift=0em]nc21.east) {}; \node [anchor=west,snode,fill=yellow!30] (nc22) at ([xshift=-0.06em,yshift=0em]nc21.east) {};
\node [anchor=west,snode,fill=red!30] (nc23) at ([xshift=0em,yshift=0em]nc22.east) {}; \node [anchor=west,snode,fill=red!30] (nc23) at ([xshift=-0.06em,yshift=0em]nc22.east) {};
\node [anchor=west,snode,fill=blue!30] (nc24) at ([xshift=0em,yshift=0em]nc23.east) {}; \node [anchor=west,snode,fill=blue!30] (nc24) at ([xshift=-0.06em,yshift=0em]nc23.east) {};
\node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc25) at ([xshift=0em,yshift=0em]nc24.east) {$\mathbi{o}_5^2$}; \node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc25) at ([xshift=-0.06em,yshift=0em]nc24.east) {$\mathbi{o}_5^2$};
\node [anchor=west,snode,fill=purple!30] (nc31) at ([xshift=1.2em,yshift=0em]n6.east) {}; \node [anchor=west,snode,fill=purple!30] (nc31) at ([xshift=1.2em,yshift=0em]n6.east) {};
\node [anchor=west,snode,fill=yellow!30] (nc32) at ([xshift=0em,yshift=0em]nc31.east) {}; \node [anchor=west,snode,fill=yellow!30] (nc32) at ([xshift=-0.06em,yshift=0em]nc31.east) {};
\node [anchor=west,snode,fill=red!30] (nc33) at ([xshift=0em,yshift=0em]nc32.east) {}; \node [anchor=west,snode,fill=red!30] (nc33) at ([xshift=-0.06em,yshift=0em]nc32.east) {};
\node [anchor=west,snode,fill=blue!30] (nc34) at ([xshift=0em,yshift=0em]nc33.east) {}; \node [anchor=west,snode,fill=blue!30] (nc34) at ([xshift=-0.06em,yshift=0em]nc33.east) {};
\node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc35) at ([xshift=0em,yshift=0em]nc34.east) {$\mathbi{o}_5^1$}; \node [anchor=west,snode,font=\footnotesize,fill=ugreen!30] (nc35) at ([xshift=-0.06em,yshift=0em]nc34.east) {$\mathbi{o}_5^1$};
\node [anchor=south,lnode] (n8) at ([xshift=0em,yshift=1em]nc13.north) {$\mathbi{W}_2$}; \node [anchor=south,lnode] (n8) at ([xshift=0em,yshift=1em]nc13.north) {$\mathbi{W}_2$};
\node [anchor=west,font=\footnotesize] (n9) at ([xshift=0.1em,yshift=0.5em]nc25.east) {Softmax}; \node [anchor=west,font=\footnotesize] (n9) at ([xshift=0.1em,yshift=0.5em]nc25.east) {Softmax};
\node [anchor=west,snode,fill=purple!30] (ns11) at ([xshift=3.5em,yshift=0em]nc15.east) {}; \node [anchor=west,snode,fill=purple!30] (ns11) at ([xshift=3.5em,yshift=0em]nc15.east) {};
\node [anchor=west,snode,fill=yellow!30] (ns12) at ([xshift=0em,yshift=0em]ns11.east) {}; \node [anchor=west,snode,fill=yellow!30] (ns12) at ([xshift=-0.06em,yshift=0em]ns11.east) {};
\node [anchor=west,snode,fill=red!30] (ns13) at ([xshift=0em,yshift=0em]ns12.east) {}; \node [anchor=west,snode,fill=red!30] (ns13) at ([xshift=-0.06em,yshift=0em]ns12.east) {};
\node [anchor=west,snode,fill=blue!30] (ns14) at ([xshift=0em,yshift=0em]ns13.east) {}; \node [anchor=west,snode,fill=blue!30] (ns14) at ([xshift=-0.06em,yshift=0em]ns13.east) {};
\node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns15) at ([xshift=0em,yshift=0em]ns14.east) {0.3}; \node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns15) at ([xshift=-0.06em,yshift=0em]ns14.east) {0.3};
\node [anchor=west,snode,fill=purple!30] (ns21) at ([xshift=3.5em,yshift=0em]nc25.east) {}; \node [anchor=west,snode,fill=purple!30] (ns21) at ([xshift=3.5em,yshift=0em]nc25.east) {};
\node [anchor=west,snode,fill=yellow!30] (ns22) at ([xshift=0em,yshift=0em]ns21.east) {}; \node [anchor=west,snode,fill=yellow!30] (ns22) at ([xshift=-0.06em,yshift=0em]ns21.east) {};
\node [anchor=west,snode,fill=red!30] (ns23) at ([xshift=0em,yshift=0em]ns22.east) {}; \node [anchor=west,snode,fill=red!30] (ns23) at ([xshift=-0.06em,yshift=0em]ns22.east) {};
\node [anchor=west,snode,fill=blue!30] (ns24) at ([xshift=0em,yshift=0em]ns23.east) {}; \node [anchor=west,snode,fill=blue!30] (ns24) at ([xshift=-0.06em,yshift=0em]ns23.east) {};
\node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns25) at ([xshift=0em,yshift=0em]ns24.east) {0.2}; \node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns25) at ([xshift=-0.06em,yshift=0em]ns24.east) {0.2};
\node [anchor=west,snode,fill=purple!30] (ns31) at ([xshift=3.5em,yshift=0em]nc35.east) {}; \node [anchor=west,snode,fill=purple!30] (ns31) at ([xshift=3.5em,yshift=0em]nc35.east) {};
\node [anchor=west,snode,fill=yellow!30] (ns32) at ([xshift=0em,yshift=0em]ns31.east) {}; \node [anchor=west,snode,fill=yellow!30] (ns32) at ([xshift=-0.06em,yshift=0em]ns31.east) {};
\node [anchor=west,snode,fill=red!30] (ns33) at ([xshift=0em,yshift=0em]ns32.east) {}; \node [anchor=west,snode,fill=red!30] (ns33) at ([xshift=-0.06em,yshift=0em]ns32.east) {};
\node [anchor=west,snode,fill=blue!30] (ns34) at ([xshift=0em,yshift=0em]ns33.east) {}; \node [anchor=west,snode,fill=blue!30] (ns34) at ([xshift=-0.06em,yshift=0em]ns33.east) {};
\node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns35) at ([xshift=0em,yshift=0em]ns34.east) {0.5}; \node [anchor=west,snode,font=\tiny,fill=ugreen!30] (ns35) at ([xshift=-0.06em,yshift=0em]ns34.east) {0.5};
\node [anchor=west,vlnode,fill=purple!30] (ln1) at ([xshift=3.5em,yshift=-1.5em]ns15.east) {}; \node [anchor=west,vlnode,fill=purple!30] (ln1) at ([xshift=3.5em,yshift=-1.5em]ns15.east) {};
\node [anchor=north west,vlnode,fill=yellow!30] (ln2) at ([xshift=-0.4em,yshift=-0.4em]ln1.north west) {}; \node [anchor=north west,vlnode,fill=yellow!30] (ln2) at ([xshift=-0.4em,yshift=-0.4em]ln1.north west) {};
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
\node [anchor=south,vlnode,rotate=-90] (ffn) at ([xshift=2em,yshift=0em]ln3.east) {FFN}; \node [anchor=south,vlnode,rotate=-90] (ffn) at ([xshift=2em,yshift=0em]ln3.east) {FFN};
\node [anchor=west,rectangle,inner sep=0mm,minimum height=3.5em,minimum width=0.8em,rounded corners=2pt,draw] (fn) at ([xshift=1.5em,yshift=0em]ffn.north) {$\mathbi{g}$}; \node [anchor=west,rectangle,inner sep=0mm,minimum height=3.5em,minimum width=0.8em,rounded corners=2pt,draw,thick] (fn) at ([xshift=1em,yshift=0em]ffn.north) {$\mathbi{g}$};
\draw [->,thick] ([xshift=0em,yshift=0em]n1.east) -- ([xshift=0em,yshift=0em]n4.west); \draw [->,thick] ([xshift=0em,yshift=0em]n1.east) -- ([xshift=0em,yshift=0em]n4.west);
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
\draw [decorate,decoration={brace,mirror}] ([xshift=0em]n3.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$d_{\textrm{model}}$} ([xshift=0em]n3.south east); \draw [decorate,decoration={brace,mirror}] ([xshift=0em]n3.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$d_{\textrm{model}}$} ([xshift=0em]n3.south east);
\draw [decorate,decoration={brace,mirror}] ([xshift=0em]n6.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$d_{\rm a}$} ([xshift=0em]n6.south east); \draw [decorate,decoration={brace,mirror}] ([xshift=0em]n6.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$d_{\rm a}$} ([xshift=0em]n6.south east);
\draw [decorate,decoration={brace,mirror}] ([xshift=0em]n7.north west) to node [midway,font=\small,align=center,xshift=-1.4em,yshift=-0em] {$d_{\textrm{model}}$} ([xshift=0em]n7.south west); \draw [decorate,decoration={brace,mirror}] ([xshift=0em]n7.north west) to node [midway,font=\small,align=center,xshift=-1.4em,yshift=-0em] {$d_{\textrm{model}}$} ([xshift=0em]n7.south west);
\draw [decorate,decoration={brace}] ([xshift=0em]n7.north west) to node [midway,font=\small,align=center,xshift=0em,yshift=0.7em] {$d_{\textrm{model}}$} ([xshift=0em]n7.north east); \draw [decorate,decoration={brace}] ([xshift=0em]n7.north west) to node [midway,font=\small,align=center,xshift=0em,yshift=0.7em] {$d_{\rm a}$} ([xshift=0em]n7.north east);
\draw [decorate,decoration={brace,mirror}] ([xshift=0em]n8.north west) to node [midway,font=\small,align=center,xshift=-0.8em,yshift=-0em] {$d_{\rm a}$} ([xshift=0em]n8.south west); \draw [decorate,decoration={brace,mirror}] ([xshift=0em]n8.north west) to node [midway,font=\small,align=center,xshift=-0.8em,yshift=-0em] {$d_{\rm a}$} ([xshift=0em]n8.south west);
\draw [decorate,decoration={brace}] ([xshift=0em]n8.north west) to node [midway,font=\small,align=center,xshift=0em,yshift=0.8em] {$n_{\rm hop}$} ([xshift=0em]n8.north east); \draw [decorate,decoration={brace}] ([xshift=0em]n8.north west) to node [midway,font=\small,align=center,xshift=0em,yshift=0.8em] {$n_{\rm hop}$} ([xshift=0em]n8.north east);
\draw [decorate,decoration={brace,mirror}] ([xshift=0em]nc31.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$n_{\rm hop}$} ([xshift=0em]nc35.south east); \draw [decorate,decoration={brace,mirror}] ([xshift=0em]nc31.south west) to node [midway,font=\small,align=center,xshift=0em,yshift=-0.8em] {$n_{\rm hop}$} ([xshift=0em]nc35.south east);
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=4em,minimum width=4em,rounded corners=5pt,thick,draw,fill=blue!15] \tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=4em,minimum width=4em,rounded corners=5pt,thick,draw,fill=blue!30]
\tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=6em,rounded corners=5pt,thick,fill=red!15,draw] \tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=6em,rounded corners=5pt,thick,fill=red!30,draw]
\tikzstyle{ebnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,fill=ugreen!15,draw] \tikzstyle{ebnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,fill=green!30,draw]
\begin{scope}[] \begin{scope}[]
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
\node [anchor=south east,manode] (c1) at ([xshift=0em,yshift=1em]e1.north east){Conv}; \node [anchor=south east,manode] (c1) at ([xshift=0em,yshift=1em]e1.north east){Conv};
\node [anchor=south west,ebnode] (e2) at ([xshift=0em,yshift=1em]a1.north west){Embedding}; \node [anchor=south west,ebnode] (e2) at ([xshift=0em,yshift=1em]a1.north west){Embedding};
\node [anchor=south,draw,circle,inner sep=4pt] (add1) at ([xshift=0em,yshift=0.5em]e2.north){}; \node [anchor=south,draw,circle,inner sep=4pt] (add1) at ([xshift=0em,yshift=0.5em]e2.north){};
\node [anchor=south,inner sep=0mm,minimum height=1.8em] (f2) at ([xshift=0em,yshift=0.5em]add1.north){output}; \node [anchor=south,ffnnode] (f2) at ([xshift=0em,yshift=0.5em]add1.north){FFN};
\node [anchor=south,inner sep=0mm,minimum height=1.8em] (op) at ([xshift=0em,yshift=0.5em]f2.north){output};
\draw[->,thick] ([xshift=0em,yshift=-0.3em]f1.north)--([xshift=0em,yshift=0em]e1.south); \draw[->,thick] ([xshift=0em,yshift=-0.3em]f1.north)--([xshift=0em,yshift=0em]e1.south);
...@@ -24,7 +25,9 @@ ...@@ -24,7 +25,9 @@
\draw[->,thick] ([xshift=0em,yshift=0em]a1.north)--([xshift=0em,yshift=1em]a1.north); \draw[->,thick] ([xshift=0em,yshift=0em]a1.north)--([xshift=0em,yshift=1em]a1.north);
\draw[->,thick] ([xshift=0em,yshift=0em]c1.north)--([xshift=0em,yshift=1em]c1.north); \draw[->,thick] ([xshift=0em,yshift=0em]c1.north)--([xshift=0em,yshift=1em]c1.north);
\draw[-,thick] ([xshift=0em,yshift=0em]e2.north)--([xshift=0em,yshift=0em]add1.south); \draw[-,thick] ([xshift=0em,yshift=0em]e2.north)--([xshift=0em,yshift=0em]add1.south);
\draw[->,thick] ([xshift=0em,yshift=0em]add1.north)--([xshift=0em,yshift=0.3em]f2.south); \draw[->,thick] ([xshift=0em,yshift=0em]add1.north)--([xshift=0em,yshift=0em]f2.south);
\draw[->,thick] ([xshift=0em,yshift=0em]f2.north)--([xshift=0em,yshift=0.3em]op.south);
\draw[-] ([xshift=0em,yshift=0em]add1.west)--([xshift=-0em,yshift=0em]add1.east); \draw[-] ([xshift=0em,yshift=0em]add1.west)--([xshift=-0em,yshift=0em]add1.east);
\draw[-] ([xshift=0em,yshift=0em]add1.south)--([xshift=-0em,yshift=-0em]add1.north); \draw[-] ([xshift=0em,yshift=0em]add1.south)--([xshift=-0em,yshift=-0em]add1.north);
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,draw,fill=teal!20] \tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,draw,fill=teal!30]
\tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,thick,fill=red!20,draw] \tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,thick,fill=red!30,draw]
\tikzstyle{lnnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=2.5em,rounded corners=5pt,thick,fill=green!20,draw] \tikzstyle{lnnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=2.5em,rounded corners=5pt,thick,fill=green!30,draw]
\begin{scope}[] \begin{scope}[]
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
\node [anchor=west,ublue,font=\footnotesize,align=left] (w1) at ([xshift=5em,yshift=-0.5em]a2.east){以概率\\$p$丢弃}; \node [anchor=west,ublue,font=\footnotesize,align=left] (w1) at ([xshift=5em,yshift=-0.5em]a2.east){以概率\\$p$丢弃};
\node [anchor=west,ublue,font=\footnotesize,align=left] (w2) at ([xshift=0.5em,yshift=0em]f1.east){以概率\\$p$丢弃}; \node [anchor=west,ublue,font=\footnotesize,align=left] (w2) at ([xshift=0.5em,yshift=0em]f1.east){以概率\\$p$丢弃};
\draw[-] ([xshift=0em,yshift=0em]n2.west)--([xshift=-0em,yshift=0em]n2.east); \draw[-,thick] ([xshift=0em,yshift=0em]n2.west)--([xshift=-0em,yshift=0em]n2.east);
\draw[-] ([xshift=0em,yshift=0em]n2.south)--([xshift=-0em,yshift=-0em]n2.north); \draw[-,thick] ([xshift=0em,yshift=0em]n2.south)--([xshift=-0em,yshift=-0em]n2.north);
\draw[-] ([xshift=0em,yshift=0em]n5.west)--([xshift=-0em,yshift=0em]n5.east); \draw[-,thick] ([xshift=0em,yshift=0em]n5.west)--([xshift=-0em,yshift=0em]n5.east);
\draw[-] ([xshift=0em,yshift=0em]n5.south)--([xshift=-0em,yshift=-0em]n5.north); \draw[-,thick] ([xshift=0em,yshift=0em]n5.south)--([xshift=-0em,yshift=-0em]n5.north);
\end{scope} \end{scope}
\end{tikzpicture} \end{tikzpicture}
......
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\tikzstyle{cirnode}=[rectangle,rounded corners=2pt,minimum height=2em,minimum width=3em,font=\footnotesize,draw=blue!50!white!50,fill=blue!20,thick] \tikzstyle{cirnode}=[rectangle,rounded corners=2pt,minimum height=2em,minimum width=3em,font=\footnotesize,draw,fill=blue!20,thick]
\tikzstyle{recnode}=[rectangle,rounded corners=2pt,inner sep=0mm,minimum height=1.8em,minimum width=6em] \tikzstyle{recnode}=[rectangle,rounded corners=2pt,inner sep=0mm,minimum height=1.8em,minimum width=6em]
\node [anchor=west,cirnode] (n1) at (0, 0) {$\mathbi{h}_{i-2}^l$}; \node [anchor=west,cirnode] (n1) at (0, 0) {$\mathbi{h}_{i-2}^l$};
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
\node [anchor=center,orange!30,minimum height=2.5em,minimum width=4em,very thick,draw] (c1) at ([xshift=0em,yshift=0em]n3.center) {}; \node [anchor=center,orange!30,minimum height=2.5em,minimum width=4em,very thick,draw] (c1) at ([xshift=0em,yshift=0em]n3.center) {};
\end{pgfonlayer} \end{pgfonlayer}
\node [anchor=south,recnode,fill=red!20] (r1) at ([xshift=-3.5em,yshift=2.5em]n2.north) {$\textrm{head}_1$}; \node [anchor=south,recnode,fill=red!30] (r1) at ([xshift=-3.5em,yshift=2.5em]n2.north) {$\textrm{head}_1$};
\node [anchor=south,recnode,fill=orange!20] (r2) at ([xshift=0em,yshift=2.5em]n3.north) {$\textrm{head}_2$}; \node [anchor=south,recnode,fill=orange!30] (r2) at ([xshift=0em,yshift=2.5em]n3.north) {$\textrm{head}_2$};
\node [anchor=south,recnode,fill=ugreen!20] (r3) at ([xshift=3.5em,yshift=2.5em]n4.north) {$\textrm{head}_3$}; \node [anchor=south,recnode,fill=ugreen!30] (r3) at ([xshift=3.5em,yshift=2.5em]n4.north) {$\textrm{head}_3$};
\node [anchor=south,cirnode] (n6) at ([xshift=0em,yshift=1.5em]r2.north) {$\mathbi{h}_{i}^{l+1}$}; \node [anchor=south,cirnode] (n6) at ([xshift=0em,yshift=1.5em]r2.north) {$\mathbi{h}_{i}^{l+1}$};
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\tikzstyle{enode}=[rectangle,inner sep=0mm,minimum height=5em,minimum width=5em,rounded corners=7pt,fill=green!30] \tikzstyle{enode}=[rectangle,inner sep=0mm,minimum height=5em,minimum width=5em,rounded corners=7pt,fill=green!30,draw,thick]
\tikzstyle{dnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=6.5em,rounded corners=5pt,fill=red!30] \tikzstyle{dnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=6.5em,rounded corners=5pt,fill=red!30,draw,thick]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=2em,minimum width=4em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=2em,minimum width=4em]
\node [anchor=south west] (w1) at (0,0) {汉语(源语言)}; \node [anchor=south west] (w1) at (0,0) {汉语(源语言)};
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=blue!30] \tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=blue!30,draw,thick]
\tikzstyle{arnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=red!30] \tikzstyle{arnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=red!30,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em] \tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em]
{\small {\small
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
\begin{scope}[minimum height = 20pt] \begin{scope}[minimum height = 20pt]
\node [anchor=east] (x1) at (-0.5em, 0) {$\mathbi{x}_l$}; \node [anchor=east] (x1) at (-0.5em, 0) {$\mathbi{x}_l$};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (F1) at ([xshift=4em]x1.east){\small{$F$}}; \node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt,thick] (F1) at ([xshift=4em]x1.east){\small{$F$}};
\node [anchor=west,circle,draw,minimum size=1em] (n1) at ([xshift=4em]F1.east) {}; \node [anchor=west,circle,draw,minimum size=1em] (n1) at ([xshift=4em]F1.east) {};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (ln1) at ([xshift=4em]n1.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt,thick] (ln1) at ([xshift=4em]n1.east){\small{\textrm{LN}}};
\node [anchor=west] (x2) at ([xshift=4em]ln1.east) {$\mathbi{x}_{l+1}$}; \node [anchor=west] (x2) at ([xshift=4em]ln1.east) {$\mathbi{x}_{l+1}$};
\node [anchor=north] (x3) at ([yshift=-5em]x1.south) {$\mathbi{x}_l$}; \node [anchor=north] (x3) at ([yshift=-5em]x1.south) {$\mathbi{x}_l$};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (F2) at ([xshift=4em]x3.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt,thick] (F2) at ([xshift=4em]x3.east){\small{\textrm{LN}}};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (ln2) at ([xshift=4em]F2.east){\small{$F$}}; \node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt,thick] (ln2) at ([xshift=4em]F2.east){\small{$F$}};
\node [anchor=west,circle,draw,,minimum size=1em] (n2) at ([xshift=4em]ln2.east){}; \node [anchor=west,circle,draw,,minimum size=1em] (n2) at ([xshift=4em]ln2.east){};
\node [anchor=west] (x4) at ([xshift=4em]n2.east) {$\mathbi{x}_{l+1}$}; \node [anchor=west] (x4) at ([xshift=4em]n2.east) {$\mathbi{x}_{l+1}$};
......
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{Sanode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw]; \tikzstyle{Sanode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,thick];
\tikzstyle{Resnode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw]; \tikzstyle{Resnode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,thick];
\tikzstyle{ffnnode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw]; \tikzstyle{ffnnode} = [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,thick];
\tikzstyle{outputnode} = [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw]; \tikzstyle{outputnode} = [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,thick];
\tikzstyle{inputnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!20]; \tikzstyle{inputnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!20,thick];
\tikzstyle{posnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!10!white]; \tikzstyle{posnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!10!white,thick];
\tikzstyle{standard} = [rounded corners=3pt]; \tikzstyle{standard} = [rounded corners=3pt];
\begin{scope} \begin{scope}
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{node}=[minimum height=6em,inner sep=4pt,align=left,draw,font=\footnotesize,rounded corners=4pt,thick,drop shadow] \tikzstyle{node}=[minimum height=6em,inner sep=4pt,align=left,draw,font=\footnotesize,rounded corners=4pt,thick,drop shadow]
\node[node,fill=red!20] (n1) at (0,0){\scriptsize\bfnew{超网络}\\ [1ex] 模型结构参数 \\[0.4ex] 网络参数}; \node[node,fill=red!30] (n1) at (0,0){\scriptsize\bfnew{超网络}\\ [1ex] 模型结构参数 \\[0.4ex] 网络参数};
\node[anchor=west,node,fill=yellow!20] (n2) at ([xshift=4em]n1.east){\scriptsize\bfnew{优化后的超网络}\\ [1ex]模型{\color{red}结构参数}(已优化) \\ [0.4ex]网络参数(已优化)}; \node[anchor=west,node,fill=yellow!30] (n2) at ([xshift=4em]n1.east){\scriptsize\bfnew{优化后的超网络}\\ [1ex]模型{\color{red}结构参数}(已优化) \\ [0.4ex]网络参数(已优化)};
\node[anchor=west,node,fill=green!20] (n3) at ([xshift=6em]n2.east){\scriptsize\bfnew{找到的模型结构}}; \node[anchor=west,node,fill=green!30] (n3) at ([xshift=6em]n2.east){\scriptsize\bfnew{找到的模型结构}};
\draw[-latex,thick] (n1.0) -- node[above,align=center,font=\scriptsize]{优化后的\\超网络}(n2.180); \draw[-latex,thick] (n1.0) -- node[above,align=center,font=\scriptsize]{优化后的\\超网络}(n2.180);
\draw[-latex,thick] (n2.0) -- node[above,align=center,font=\scriptsize]{根据结构参数\\离散化结构}(n3.180); \draw[-latex,thick] (n2.0) -- node[above,align=center,font=\scriptsize]{根据结构参数\\离散化结构}(n3.180);
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
%%% outline %%% outline
%------------------------------------------------------------------------- %-------------------------------------------------------------------------
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{node}=[minimum height=2em,minimum width=5em,draw,rounded corners=2pt,thick,drop shadow] \tikzstyle{node}=[minimum height=2.5em,minimum width=8em,draw,rounded corners=2pt,thick,drop shadow]
\node[node,fill=red!20] (n1) at (0,0){\small\bfnew{环境}}; \node[node,fill=red!30] (n1) at (0,0){\small\bfnew{环境}};
\node[anchor=south,node,fill=green!20] (n2) at ([yshift=5em]n1.north){\small\bfnew{智能体}}; \node[anchor=south,node,fill=green!30] (n2) at ([yshift=5em]n1.north){\small\bfnew{智能体}};
\node[anchor=north,font=\footnotesize] at ([yshift=-0.2em]n1.south){(结构所应用于的任务)}; \node[anchor=north,font=\footnotesize] at ([yshift=-0.2em]n1.south){(结构所应用于的任务)};
\node[anchor=south,font=\footnotesize] at ([yshift=0.2em]n2.north){(结构生成器)}; \node[anchor=south,font=\footnotesize] at ([yshift=0.2em]n2.north){(结构生成器)};
\draw[-latex,thick] ([yshift=.4em]n1.180) .. controls ([xshift=-3.4em,yshift=.4em]n1.180) and ([xshift=-3.4em,yshift=-.4em]n2.180) .. node[right,font=\scriptsize,align=left]{\scriptsize\bfnew{奖励} \\ (对输出结果的评价)}([yshift=-.4em]n2.180); \draw[-latex,thick] ([yshift=.4em]n1.180) .. controls ([xshift=-3.4em,yshift=.4em]n1.180) and ([xshift=-3.4em,yshift=-.4em]n2.180) .. node[right,font=\scriptsize,align=left]{\scriptsize\bfnew{奖励} \\ (对输出结果的评价)}([yshift=-.4em]n2.180);
\draw[-latex,thick] ([yshift=-.4em]n1.180) .. controls ([xshift=-4.4em,yshift=-.4em]n1.180) and ([xshift=-4.4em,yshift=.4em]n2.180) .. node[left,font=\scriptsize,align=right]{\scriptsize\bfnew{状态} \\ (这个结构在任务中应\\ 后得到的输出结果)}([yshift=.4em]n2.180); \draw[-latex,thick] ([yshift=-.4em]n1.180) .. controls ([xshift=-4.4em,yshift=-.4em]n1.180) and ([xshift=-4.4em,yshift=.4em]n2.180) .. node[left,font=\scriptsize,align=right]{\scriptsize\bfnew{状态} \\ (这个结构在任务中应 \\后得到的输出结果)}([yshift=.4em]n2.180);
\draw[-latex,thick] (n2.0) .. controls ([xshift=4em]n2.0) and ([xshift=4em]n1.0) .. node[right,font=\scriptsize,align=left]{\scriptsize\bfnew{动作} \\ (生成一个结构)}(n1.0); \draw[-latex,thick] (n2.0) .. controls ([xshift=4em]n2.0) and ([xshift=4em]n1.0) .. node[right,font=\scriptsize,align=left]{\scriptsize\bfnew{动作} \\ (生成一个结构)}(n1.0);
\end{tikzpicture} \end{tikzpicture}
......
...@@ -6,24 +6,24 @@ ...@@ -6,24 +6,24 @@
\begin{scope}[minimum height = 20pt] \begin{scope}[minimum height = 20pt]
\node [anchor=east] (x1) at (-0.5em, 0) {$\mathbi{x}_l$}; \node [anchor=east] (x1) at (-0.5em, 0) {$\mathbi{x}_l$};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (ln1) at ([xshift=1em]x1.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=red!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (ln1) at ([xshift=1em]x1.east){\small{\textrm{LN}}};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (f1) at ([xshift=0.6em]ln1.east){\small{$F$}}; \node [anchor=west,draw,fill=green!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (f1) at ([xshift=0.6em]ln1.east){\small{$F$}};
\node [anchor=west,circle,draw,,minimum size=1em] (n1) at ([xshift=3em]f1.east){}; \node [anchor=west,circle,draw,,minimum size=1em] (n1) at ([xshift=3em]f1.east){};
\node [anchor=west] (x2) at ([xshift=1em]n1.east) {$\mathbi{x}_{l+1}$}; \node [anchor=west] (x2) at ([xshift=1em]n1.east) {$\mathbi{x}_{l+1}$};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (ln12) at ([xshift=1em]x2.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=red!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (ln12) at ([xshift=1em]x2.east){\small{\textrm{LN}}};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (f12) at ([xshift=0.6em]ln12.east){\small{$F$}}; \node [anchor=west,draw,fill=green!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (f12) at ([xshift=0.6em]ln12.east){\small{$F$}};
\node [anchor=west,circle,draw,,minimum size=1em] (n12) at ([xshift=3em]f12.east){}; \node [anchor=west,circle,draw,,minimum size=1em] (n12) at ([xshift=3em]f12.east){};
\node [anchor=west] (x22) at ([xshift=1em]n12.east) {$\mathbi{x}_{l+2}$}; \node [anchor=west] (x22) at ([xshift=1em]n12.east) {$\mathbi{x}_{l+2}$};
\node [anchor=north] (x3) at ([yshift=-5em]x1.south) {$\mathbi{x}_l$}; \node [anchor=north] (x3) at ([yshift=-5em]x1.south) {$\mathbi{x}_l$};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (ln2) at ([xshift=1em]x3.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=red!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (ln2) at ([xshift=1em]x3.east){\small{\textrm{LN}}};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (f2) at ([xshift=0.6em]ln2.east){\small{$F$}}; \node [anchor=west,draw,fill=green!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (f2) at ([xshift=0.6em]ln2.east){\small{$F$}};
\node [anchor=west,minimum size=1em] (p1) at ([xshift=1em]f2.east){}; \node [anchor=west,minimum size=1em] (p1) at ([xshift=1em]f2.east){};
\node [anchor=north] (m1) at ([yshift=0.6em]p1.south){\footnotesize{\red{Mask=1}}}; \node [anchor=north] (m1) at ([yshift=0.6em]p1.south){\footnotesize{\red{Mask=1}}};
\node [anchor=west,circle,draw,,minimum size=1em] (n2) at ([xshift=3em]f2.east){}; \node [anchor=west,circle,draw,,minimum size=1em] (n2) at ([xshift=3em]f2.east){};
\node [anchor=west] (x4) at ([xshift=1em]n2.east) {$\mathbi{x}_{l+1}$}; \node [anchor=west] (x4) at ([xshift=1em]n2.east) {$\mathbi{x}_{l+1}$};
\node [anchor=west,draw,fill=red!20,inner xsep=5pt,rounded corners=2pt] (ln22) at ([xshift=1em]x4.east){\small{\textrm{LN}}}; \node [anchor=west,draw,fill=red!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (ln22) at ([xshift=1em]x4.east){\small{\textrm{LN}}};
\node [anchor=west,draw,fill=green!20,inner xsep=5pt,rounded corners=2pt] (f22) at ([xshift=0.6em]ln22.east){\small{$F$}}; \node [anchor=west,draw,fill=green!30,inner xsep=5pt,rounded corners=2pt,draw,thick] (f22) at ([xshift=0.6em]ln22.east){\small{$F$}};
\node [anchor=west,minimum size=1em] (p2) at ([xshift=1em]f22.east){}; \node [anchor=west,minimum size=1em] (p2) at ([xshift=1em]f22.east){};
\node [anchor=north] (m2) at ([yshift=0.6em]p2.south){\footnotesize{\red{Mask=0}}}; \node [anchor=north] (m2) at ([yshift=0.6em]p2.south){\footnotesize{\red{Mask=0}}};
\node [anchor=west,circle,draw,,minimum size=1em] (n22) at ([xshift=3em]f22.east){}; \node [anchor=west,circle,draw,,minimum size=1em] (n22) at ([xshift=3em]f22.east){};
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=blue!30] \tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=blue!30,draw,thick]
\tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=orange!30] \tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=orange!30,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em] \tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.6em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.6em]
{\small {\small
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=blue!30] \tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=blue!30,draw,thick]
\tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=orange!30] \tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=orange!30,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em] \tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em]
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
\node [anchor=south,wnode] (w10) at ([xshift=0em,yshift=0.5em]c3.north) {$\mathbi{e}_{w_2}$}; \node [anchor=south,wnode] (w10) at ([xshift=0em,yshift=0.5em]c3.north) {$\mathbi{e}_{w_2}$};
\begin{pgfonlayer}{background} \begin{pgfonlayer}{background}
\node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!20,rounded corners=8pt] [fit = (c1) (w8)] (box6) {}; \node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!30,rounded corners=8pt,draw,thick] [fit = (c1) (w8)] (box6) {};
\node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!20,rounded corners=8pt] [fit = (c2) (w9)] (box7) {}; \node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!30,rounded corners=8pt,draw,thick] [fit = (c2) (w9)] (box7) {};
\node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!20,rounded corners=8pt] [fit = (c3) (w10)] (box8) {}; \node [rectangle,minimum height=5em,inner sep=0.6em,fill=green!30,rounded corners=8pt,draw,thick] [fit = (c3) (w10)] (box8) {};
\end{pgfonlayer} \end{pgfonlayer}
\node [anchor=south,wrnode] (wr1) at ([xshift=0em,yshift=1em]box6.north) {$\mathbi{h}_{w_1}$}; \node [anchor=south,wrnode] (wr1) at ([xshift=0em,yshift=1em]box6.north) {$\mathbi{h}_{w_1}$};
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=red!30] \tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=red!30,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em] \tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.6em] \tikzstyle{wnode}=[inner sep=0mm,minimum height=1.6em]
{\small {\small
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
\begin{figure}[htp] \begin{figure}[htp]
\centering \centering
\input{./Chapter15/Figures/figure-relative-position-coding-and-absolute-position-coding} \input{./Chapter15/Figures/figure-relative-position-coding-and-absolute-position-coding}
\caption{绝对位置编码(左)和相对位置编码(右)} \caption{绝对位置编码和相对位置编码}
\label{fig:15-1} \label{fig:15-1}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
...@@ -118,7 +118,6 @@ ...@@ -118,7 +118,6 @@
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
\noindent 相比于公式\eqref{eq:15-4},公式\eqref{eq:15-10}在计算$\mathbi{z}_i$时引入了额外的向量$\mathbi{a}_{ij}^V$,用它来表示位置$i$与位置$j$之间的相对位置信息。同时在计算注意力权重时对$\mathbi{K}$进行修改,同样引入了$\mathbi{a}_{ij}^K$向量表示位置$i$与位置$j$之间的相对位置。在公式\eqref{eq:15-6}的基础上,注意力权重的计算方式调整为: \noindent 相比于公式\eqref{eq:15-4},公式\eqref{eq:15-10}在计算$\mathbi{z}_i$时引入了额外的向量$\mathbi{a}_{ij}^V$,用它来表示位置$i$与位置$j$之间的相对位置信息。同时在计算注意力权重时对$\mathbi{K}$进行修改,同样引入了$\mathbi{a}_{ij}^K$向量表示位置$i$与位置$j$之间的相对位置。在公式\eqref{eq:15-6}的基础上,注意力权重的计算方式调整为:
\begin{eqnarray} \begin{eqnarray}
\mathbi{e}_{ij} &=& \frac{\mathbi{x}_i \mathbi{W}_Q{(\mathbi{x}_j \mathbi{W}_K + \mathbi{a}_{ij}^K )}^{T}}{\sqrt{d_k}} \nonumber \\ \mathbi{e}_{ij} &=& \frac{\mathbi{x}_i \mathbi{W}_Q{(\mathbi{x}_j \mathbi{W}_K + \mathbi{a}_{ij}^K )}^{T}}{\sqrt{d_k}} \nonumber \\
...@@ -624,7 +623,6 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x} ...@@ -624,7 +623,6 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x}
\end{eqnarray} \end{eqnarray}
\parinterval 其中$\textrm{Var}(\cdot)$表示求方差操作,由于在大多数情况下,现有模型中的各种标准化方法可以维持$E[w_j]^2$$E[x_j]^2$等于或者近似为0。因此,模型中一层神经元输出的方差可以表示为: \parinterval 其中$\textrm{Var}(\cdot)$表示求方差操作,由于在大多数情况下,现有模型中的各种标准化方法可以维持$E[w_j]^2$$E[x_j]^2$等于或者近似为0。因此,模型中一层神经元输出的方差可以表示为:
\begin{eqnarray} \begin{eqnarray}
\textrm{Var}(\mathbi{Z}) &=& \sum_{j=1}^{n_i}{\textrm{Var}(x_j) \textrm{Var}(w_j)} \nonumber \\ \textrm{Var}(\mathbi{Z}) &=& \sum_{j=1}^{n_i}{\textrm{Var}(x_j) \textrm{Var}(w_j)} \nonumber \\
&=& {n_i}\textrm{Var}(\mathbi{W})\textrm{Var}(\mathbi{X}) &=& {n_i}\textrm{Var}(\mathbi{W})\textrm{Var}(\mathbi{X})
...@@ -667,7 +665,7 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x} ...@@ -667,7 +665,7 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x}
&=& \frac{\mathbi{w}}{\bm \sigma} \cdot \mathbi{x}_{l+1}^{\textrm{pre}}-\frac{\mathbi{w}}{\bm \sigma} \cdot {\bm \mu}+\mathbi{b} &=& \frac{\mathbi{w}}{\bm \sigma} \cdot \mathbi{x}_{l+1}^{\textrm{pre}}-\frac{\mathbi{w}}{\bm \sigma} \cdot {\bm \mu}+\mathbi{b}
\label{eq:15-45} \label{eq:15-45}
\end{eqnarray} \end{eqnarray}
\vspace{0.5em} %\vspace{0.5em}
\end{itemize} \end{itemize}
\parinterval 可以看到相比于Pre-Norm的计算方式,基于Post-Norm的Transformer中子层的输出为Pre-Norm形式的$\frac{\mathbi{w}}{\bm \sigma}$倍。当$\frac{\mathbi{w}}{\bm \sigma}<1$时,$\mathbi{x}_l$较小,输入与输出之间差异过大,导致深层Transformer系统难以收敛。Lipschitz 初始化策略通过维持条件$\frac{\mathbi{w}}{\bm \sigma}>1$,保证网络输入与输出范数一致,进而缓解梯度消失的问题\upcite{DBLP:conf/acl/XuLGXZ20}。一般情况下,$\mathbi{w}$可以被初始化为1,因此Lipschitz 初始化方法最终的约束条件则为: \parinterval 可以看到相比于Pre-Norm的计算方式,基于Post-Norm的Transformer中子层的输出为Pre-Norm形式的$\frac{\mathbi{w}}{\bm \sigma}$倍。当$\frac{\mathbi{w}}{\bm \sigma}<1$时,$\mathbi{x}_l$较小,输入与输出之间差异过大,导致深层Transformer系统难以收敛。Lipschitz 初始化策略通过维持条件$\frac{\mathbi{w}}{\bm \sigma}>1$,保证网络输入与输出范数一致,进而缓解梯度消失的问题\upcite{DBLP:conf/acl/XuLGXZ20}。一般情况下,$\mathbi{w}$可以被初始化为1,因此Lipschitz 初始化方法最终的约束条件则为:
...@@ -800,14 +798,14 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x} ...@@ -800,14 +798,14 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x}
\item 在训练的初期,模型会先经历一个学习率预热的过程: \item 在训练的初期,模型会先经历一个学习率预热的过程:
\begin{eqnarray} \begin{eqnarray}
lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num \cdot warmup\_steps^{-0.5} lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num \cdot warmup\_steps^{-0.5}
\label{eq:15-46} \label{eq:15-49}
\end{eqnarray} \end{eqnarray}
\noindent 这里,$step\_num$表示参数更新的次数,$warmup\_step$表示预热的更新次数,$d_{\textrm{model}}$表示Transformer模型的隐层大小,$lr$是学习率。 \noindent 这里,$step\_num$表示参数更新的次数,$warmup\_step$表示预热的更新次数,$d_{\textrm{model}}$表示Transformer模型的隐层大小,$lr$是学习率。
\vspace{0.5em} \vspace{0.5em}
\item 在之后的训练过程中,每当增加模型深度时,学习率都会重置到峰值,之后进行相应的衰减: \item 在之后的训练过程中,每当增加模型深度时,学习率都会重置到峰值,之后进行相应的衰减:
\begin{eqnarray} \begin{eqnarray}
lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\label{eq:15-47} \label{eq:15-50}
\end{eqnarray} \end{eqnarray}
\noindent 这里$step\_num$代表学习率重置后更新的步数。 \noindent 这里$step\_num$代表学习率重置后更新的步数。
\vspace{0.5em} \vspace{0.5em}
...@@ -838,13 +836,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -838,13 +836,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\parinterval {\chapterthirteen}提到的Layer Dropout方法可以有效地缓解这个问题。以编码器为例, Layer Dropout的过程可以被描述为:在训练过程中,对自注意力子层或前馈神经网络子层进行随机丢弃,以减少不同子层之间的相互适应。这里选择Pre-Norm结构作为基础架构,它可以被描述为: \parinterval {\chapterthirteen}提到的Layer Dropout方法可以有效地缓解这个问题。以编码器为例, Layer Dropout的过程可以被描述为:在训练过程中,对自注意力子层或前馈神经网络子层进行随机丢弃,以减少不同子层之间的相互适应。这里选择Pre-Norm结构作为基础架构,它可以被描述为:
\begin{eqnarray} \begin{eqnarray}
\mathbi{x}_{l+1} &=& F(\textrm{LN}(\mathbi{x}_l)) + \mathbi{x}_l \mathbi{x}_{l+1} &=& F(\textrm{LN}(\mathbi{x}_l)) + \mathbi{x}_l
\label{eq:15-48} \label{eq:15-51}
\end{eqnarray} \end{eqnarray}
\noindent 其中,$\textrm{LN}( \cdot )$表示层标准化函数, $F( \cdot )$表示自注意力机制或者前馈神经网络,$\mathbi{x}_l$表示第$l$个子层的输入。之后,使用一个掩码$\textrm{Mask}$(值为0或1)来控制每个子层是正常计算还是丢弃。于是,该子层的计算公式可以被重写为: \noindent 其中,$\textrm{LN}( \cdot )$表示层标准化函数, $F( \cdot )$表示自注意力机制或者前馈神经网络,$\mathbi{x}_l$表示第$l$个子层的输入。之后,使用一个掩码$\textrm{Mask}$(值为0或1)来控制每个子层是正常计算还是丢弃。于是,该子层的计算公式可以被重写为:
\begin{eqnarray} \begin{eqnarray}
\mathbi{x}_{l+1} &=& \textrm{Mask} \cdot F(\textrm{LN}(\mathbi{x}_l))+\mathbi{x}_l \mathbi{x}_{l+1} &=& \textrm{Mask} \cdot F(\textrm{LN}(\mathbi{x}_l))+\mathbi{x}_l
\label{eq:15-49} \label{eq:15-52}
\end{eqnarray} \end{eqnarray}
\noindent $\textrm{Mask}=0$代表该子层被丢弃,而$\textrm{Mask}=1$代表正常进行当前子层的计算。图\ref{fig:15-19}展示了这个方法与标准Pre-Norm结构之间的区别。 \noindent $\textrm{Mask}=0$代表该子层被丢弃,而$\textrm{Mask}=1$代表正常进行当前子层的计算。图\ref{fig:15-19}展示了这个方法与标准Pre-Norm结构之间的区别。
...@@ -914,14 +912,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -914,14 +912,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\parinterval 使用句法信息的一种简单的方法是将源语言句子编码成一个二叉树结构\footnote[6]{所有句法树都可以通过二叉化方法转化为二叉树(见{\chaptereight})。},树节点的信息是由左子树和右子树变换而来,如下所示: \parinterval 使用句法信息的一种简单的方法是将源语言句子编码成一个二叉树结构\footnote[6]{所有句法树都可以通过二叉化方法转化为二叉树(见{\chaptereight})。},树节点的信息是由左子树和右子树变换而来,如下所示:
\begin{eqnarray} \begin{eqnarray}
\mathbi{h}_p &=& f_\textrm{tree}(\mathbi{h}_l,\mathbi{h}_r) \mathbi{h}_p &=& f_\textrm{tree}(\mathbi{h}_l,\mathbi{h}_r)
\label{eq:15-50} \label{eq:15-53}
\end{eqnarray} \end{eqnarray}
\noindent 其中,$\mathbi{h}_l$$\mathbi{h}_r$分别代表了左孩子节点和右孩子节点的神经网络输出(隐层状态),通过一个非线性函数$f_\textrm{tree}(\cdot,\cdot)$得到父节点的状态$\mathbi{h}_p$。 图\ref{fig:15-20} 展示了一个基于树结构的循环神经网络编码器\upcite{DBLP:conf/acl/EriguchiHT16}。这些编码器由下自上组成了一个树型结构,这种树结构的具体连接形式由句法分析决定。其中$\{\mathbi{h}_1,\ldots,\mathbi{h}_m\}$是输入序列所对应的循环神经单元(绿色部分),$\{\mathbi{h}_{m+1},\ldots,\mathbi{h}_{2m-1}\}$对应着树中的节点(红色部分),它的输出由其左右子节点通过公式\eqref{eq:15-50}计算得到。对于注意力模型,图中所有的节点都会参与上下文向量的计算,因此仅需要对{\chapterten}所描述的计算方式稍加修改,如下: \noindent 其中,$\mathbi{h}_l$$\mathbi{h}_r$分别代表了左孩子节点和右孩子节点的神经网络输出(隐层状态),通过一个非线性函数$f_\textrm{tree}(\cdot,\cdot)$得到父节点的状态$\mathbi{h}_p$。 图\ref{fig:15-20} 展示了一个基于树结构的循环神经网络编码器\upcite{DBLP:conf/acl/EriguchiHT16}。这些编码器由下自上组成了一个树型结构,这种树结构的具体连接形式由句法分析决定。其中$\{\mathbi{h}_1,\ldots,\mathbi{h}_m\}$是输入序列所对应的循环神经单元(绿色部分),$\{\mathbi{h}_{m+1},\ldots,\mathbi{h}_{2m-1}\}$对应着树中的节点(红色部分),它的输出由其左右子节点通过公式\eqref{eq:15-53}计算得到。对于注意力模型,图中所有的节点都会参与上下文向量的计算,因此仅需要对{\chapterten}所描述的计算方式稍加修改,如下:
\begin{eqnarray} \begin{eqnarray}
\mathbi{C}_j &=& \sum_{i=1}^{m}\alpha_{i,j}\mathbi{h}_i + \sum_{i=m+1}^{2m-1}\alpha_{i,j}\mathbi{h}_i \mathbi{C}_j &=& \sum_{i=1}^{m}\alpha_{i,j}\mathbi{h}_i + \sum_{i=m+1}^{2m-1}\alpha_{i,j}\mathbi{h}_i
\label{eq:15-51} \label{eq:15-54}
\end{eqnarray} \end{eqnarray}
%---------------------------------------------- %----------------------------------------------
...@@ -965,7 +962,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -965,7 +962,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\parinterval 不同于直接对树结构进行编码,另一种方法是将单词、句法信息等直接转换为特征向量拼接到一起,作为机器翻译系统的输入\upcite{DBLP:conf/wmt/SennrichH16}。这种方法的优点在于,句法信息可以无缝融入到现有神经机器翻译框架,对系统结构的修改很小。以基于循环神经网络的翻译模型为例,可以用如下方式计算输入序列第$i$个位置的表示结果: \parinterval 不同于直接对树结构进行编码,另一种方法是将单词、句法信息等直接转换为特征向量拼接到一起,作为机器翻译系统的输入\upcite{DBLP:conf/wmt/SennrichH16}。这种方法的优点在于,句法信息可以无缝融入到现有神经机器翻译框架,对系统结构的修改很小。以基于循环神经网络的翻译模型为例,可以用如下方式计算输入序列第$i$个位置的表示结果:
\begin{eqnarray} \begin{eqnarray}
\mathbi{h}_i &=& \textrm{tanh}(\mathbi{W}(\|_{k=1}^{F}\mathbi{E}_k x_{ik}) + \mathbi{U}\mathbi{h}_{i-1}) \mathbi{h}_i &=& \textrm{tanh}(\mathbi{W}(\|_{k=1}^{F}\mathbi{E}_k x_{ik}) + \mathbi{U}\mathbi{h}_{i-1})
\label{eq:15-52} \label{eq:15-55}
\end{eqnarray} \end{eqnarray}
\noindent 其中,$\mathbi{W}$$\mathbi{U}$是线性变换矩阵,$F$代表了特征的数量;而$\mathbi{E}_k$是一个特征嵌入矩阵,它记录了第$k$个特征不同取值对应的分布式表示;$x_{ik}$ 代表了第$i$ 个词在第$k$ 个特征上的取值,于是$\mathbi{E}_k x_{ik}$就得到所激活特征的嵌入结果。$\|$操作为拼接操作,它将所有特征的嵌入结果拼接为一个向量。这种方法十分灵活,可以很容易地融合不同句法特征,例如,词根、子词、形态、词性以及依存关系等。 \noindent 其中,$\mathbi{W}$$\mathbi{U}$是线性变换矩阵,$F$代表了特征的数量;而$\mathbi{E}_k$是一个特征嵌入矩阵,它记录了第$k$个特征不同取值对应的分布式表示;$x_{ik}$ 代表了第$i$ 个词在第$k$ 个特征上的取值,于是$\mathbi{E}_k x_{ik}$就得到所激活特征的嵌入结果。$\|$操作为拼接操作,它将所有特征的嵌入结果拼接为一个向量。这种方法十分灵活,可以很容易地融合不同句法特征,例如,词根、子词、形态、词性以及依存关系等。
...@@ -981,23 +978,18 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -981,23 +978,18 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
\parinterval 在对句法树结构进行序列化的基础上,可以用句法树节点与原始的词信息构造出新的融合表示${\mathbi{h}'}_i$,并使用这种新的表示计算上下文向量,如下: \parinterval 在对句法树的树结构进行序列化的基础上,可以用句法树节点与原始的词信息一同构造出新的融合表示${\mathbi{h}'}_i$,并使用这种新的表示计算上下文向量,如下:
\begin{eqnarray} \begin{eqnarray}
\mathbi{C}_j &=& \sum_{i=1}^m \alpha_{i,j} {\mathbi{h}'}_i \mathbi{C}_j &=& \sum_{i=1}^m \alpha_{i,j} {\mathbi{h}'}_i
\label{eq:15-53} \label{eq:15-56}
\end{eqnarray} \end{eqnarray}
\noindent 其中,$m$是源语言句子的长度。新的融合表示${\mathbi{h}'}_i$有如下几种计算方式\upcite{DBLP:conf/acl/LiXTZZZ17} \noindent 其中,$m$是源语言句子的长度。新的融合表示${\mathbi{h}'}_i$有如下几种计算方式\upcite{DBLP:conf/acl/LiXTZZZ17}
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 平行结构。利用两个编码器分别对源语言单词序列和线性化的句法树进行建模,之后在句法树节点序列中寻找每个单词的父节点(或者祖先节点),将这个单词和它的父节点(或者祖先节点)的状态相融合,得到新的表示。如图\ref{fig:15-23}(a)所示,图中$\mathbi{h}_{w_i}$为词$w_i$在单词序列中的状态,$\mathbi{h}_{l_j}$为树节点$l_j$在句法节点序列中的状态。如果单词$w_i$是节点$l_j$ 在句法树中的子节点,则将$\mathbi{h}_{w_i}$$\mathbi{h}_{l_j}$向量拼接到一起作为这个词的新表示${\mathbi{h}'}_i$ \item {\small\bfnew{平行结构}}。利用两个编码器分别对源语言单词序列和线性化的句法树进行建模,之后在句法树节点序列中寻找每个单词的父节点(或者祖先节点),将这个单词和它的父节点(或者祖先节点)的状态相融合,得到新的表示。如图\ref{fig:15-23}(a)所示,图中$\mathbi{h}_{w_i}$为词$w_i$在单词序列中的状态,$\mathbi{h}_{l_j}$为树节点$l_j$在句法节点序列中的状态。如果单词$w_i$是节点$l_j$ 在句法树(图\ref{fig:15-22}(a))中的子节点,则将$\mathbi{h}_{w_i}$$\mathbi{h}_{l_j}$向量拼接到一起作为这个词的新的融合表示向量${\mathbi{h}'}_i$
\vspace{0.5em}
\item 分层结构。将句法表示结果与源语言单词的词嵌入向量进行融合,如图\ref{fig:15-23}(b)所示,其中$\mathbi{e}_{w_i}$为第$i$个词的词嵌入。类似地,如果单词$w_i$是节点$l_j$在句法树中的子节点,则将$\mathbi{e}_{w_i}$$\mathbi{h}_{l_j}$向量拼接到一起作为原始模型的输入,这样${\mathbi{h}'}_i$直接参与注意力计算。注意,分层结构和平行结构的区别在于,分层结构最终还是使用了一个编码器,句法信息只是与词嵌入进行融合,因此最终的结构和原始的模型是一致的;平行结构相当于使用了两个编码器,因此单词和句法信息的融合是在两个编码器的输出上进行的;
\vspace{0.5em}
\item 混合结构。首先对图\ref{fig:15-22}(a)中句法树进行先序遍历,将句法标记和源语言单词融合到同一个序列中,得到如图\ref{fig:15-23}(c)所示序列。之后使用传统的序列编码器对这个序列进行编码,然后使用序列中源语言单词所对应的状态参与注意力模型的计算。有趣的是,相比于前两种方法,这种方法参数量少而且也十分有效\upcite{DBLP:conf/acl/LiXTZZZ17}
\vspace{0.5em} \vspace{0.5em}
\end{itemize}
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -1010,6 +1002,12 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1010,6 +1002,12 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
\item {\small\bfnew{分层结构}}。将句法表示结果与源语言单词的词嵌入向量进行融合,如图\ref{fig:15-23}(b)所示,其中$\mathbi{e}_{w_i}$为第$i$个词的词嵌入。类似地,如果单词$w_i$是节点$l_j$在句法树(图\ref{fig:15-22}(a))中的子节点,则将$\mathbi{e}_{w_i}$$\mathbi{h}_{l_j}$向量拼接到一起作为原始模型的输入,这样${\mathbi{h}'}_i$直接参与注意力计算。注意,分层结构和平行结构的区别在于,分层结构最终还是使用了一个编码器,句法信息只是与词嵌入进行融合,因此最终的结构和原始的模型是一致的;平行结构相当于使用了两个编码器,因此单词和句法信息的融合是在两个编码器的输出上进行的;
\vspace{0.5em}
\item {\small\bfnew{混合结构}}。首先对图\ref{fig:15-22}(a)中句法树进行先序遍历,将句法标记和源语言单词融合到同一个序列中,得到如图\ref{fig:15-23}(c)所示序列。之后使用传统的序列编码器对这个序列进行编码,然后使用序列中源语言单词所对应的状态参与注意力模型的计算。有趣的是,相比于前两种方法,这种方法参数量少而且也十分有效\upcite{DBLP:conf/acl/LiXTZZZ17}
\vspace{0.5em}
\end{itemize}
\parinterval 需要注意的是,句法分析的错误会在很大程度上影响源语言句子的表示结果。如果获得的句法分析结果不够准确,可能会对翻译系统带来负面的作用。此外,也有研究发现基于词串的神经机器翻译模型本身就能学习到一些源语言的句法信息\upcite{DBLP:conf/emnlp/ShiPK16},这表明了神经机器翻译模型也有一定的归纳句子结构的能力。除了循环神经网络结构,也有研究人员探索了如何在Transformer中引入树结构信息。比如,可以将词与词之间的依存关系距离作为额外的语法信息融入到注意力模型中\upcite{DBLP:conf/acl/BugliarelloO20} \parinterval 需要注意的是,句法分析的错误会在很大程度上影响源语言句子的表示结果。如果获得的句法分析结果不够准确,可能会对翻译系统带来负面的作用。此外,也有研究发现基于词串的神经机器翻译模型本身就能学习到一些源语言的句法信息\upcite{DBLP:conf/emnlp/ShiPK16},这表明了神经机器翻译模型也有一定的归纳句子结构的能力。除了循环神经网络结构,也有研究人员探索了如何在Transformer中引入树结构信息。比如,可以将词与词之间的依存关系距离作为额外的语法信息融入到注意力模型中\upcite{DBLP:conf/acl/BugliarelloO20}
%---------------------------------------------------------------------------------------- %----------------------------------------------------------------------------------------
...@@ -1018,7 +1016,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1018,7 +1016,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsection{解码器使用句法信息}\label{subsec-15.3.2} \subsection{解码器使用句法信息}\label{subsec-15.3.2}
\parinterval 在解码器中使用句法信息,一种最直接的方式是将目标语言句法树结构进行线性化,然后目标语言句子就变成了一个含有句法标记和单词的混合序列。这样,神经机器翻译系统不需要进行修改,直接使用句法树序列化的结果进行训练和推断\upcite{Aharoni2017TowardsSN}。图\ref{fig:15-24}展示了一个目标语言句法树经过线性化后的结果。 \parinterval 在解码器中使用句法信息,一种最直接的方式是将目标语言句法树结构进行线性化,然后目标语言句子就变成了一个含有句法标记和单词的混合序列。这样,神经机器翻译系统不需要进行修改,可以直接使用句法树序列化的结果进行训练和推断\upcite{Aharoni2017TowardsSN}。图\ref{fig:15-24}展示了一个目标语言句法树经过线性化后的结果。
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -1050,7 +1048,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1050,7 +1048,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{figure}[htp] \begin{figure}[htp]
\centering \centering
\input{./Chapter15/Figures/figure-parallel-RNN-structure} \input{./Chapter15/Figures/figure-parallel-RNN-structure}
\caption{词预测模型和动作模型{\color{red} 看前面的文字:一个叫动作模型,一个叫词预测模型。还有右侧图的依存的箭头方向一定再确定一下!}} \caption{词预测模型和动作模型}
\label{fig:15-26} \label{fig:15-26}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
...@@ -1083,7 +1081,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1083,7 +1081,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
\parinterval 那么网络结构搜索究竟是一种什么样的技术呢?如图\ref{fig:15-28}所示,在传统机器学习方法中,研究人员需要设计大量的特征来描述待解决的问题,即“特征工程”。在深度学习时代,神经网络模型可以完成特征的抽取和学习,但是却需要人工设计神经网络结构,这项工作仍然十分繁重。因此一些科研人员开始思考,能否将设计模型结构的工作也交由机器自动完成?深度学习方法中模型参数能够通过梯度下降等方式进行自动优化,那么模型结构是否可以也看做是一种特殊的参数,使用搜索算法自动找到最适用于当前任务的模型结构?网络结构搜索应运而生。 \parinterval 那么网络结构搜索究竟是一种什么样的技术呢?如图\ref{fig:15-28}所示,在传统机器学习方法中,研究人员需要设计大量的特征来描述待解决的问题,即“特征工程”。在深度学习时代,神经网络模型可以完成特征的抽取和学习,但是却需要人工设计神经网络结构,这项工作仍然十分繁重。因此一些科研人员开始思考,能否将设计模型结构的工作也交由机器自动完成?深度学习方法中模型参数能够通过梯度下降等方式进行自动优化,那么模型结构是否可以也看做是一种特殊的参数,使用搜索算法自动找到最适用于当前任务的模型结构?基于上述想法,网络结构搜索应运而生。
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -1094,7 +1092,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1094,7 +1092,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\end{figure} \end{figure}
%------------------------------------------- %-------------------------------------------
\parinterval 早在上世纪八十年代,研究人员就开始使用进化算法对神经网络结构进行设计\upcite{DBLP:conf/icga/MillerTH89},也引发了之后的很多探索\upcite{koza1991genetic,DBLP:conf/nips/HarpSG89,DBLP:journals/compsys/Kitano90}。近些年,随着深度学习技术的发展,网络结构搜索技术在很多任务中受到关注。例如,例如网络结构索索就很好的应用在语言建模上,并取得了很好的结果\upcite{DBLP:conf/iclr/LiuSY19,DBLP:conf/acl/LiHZXJXZLL20,DBLP:conf/emnlp/JiangHXZZ19}。下面将对网络结构搜索的基本方法和其在机器翻译中的应用进行介绍。 \parinterval 早在上世纪八十年代,研究人员就开始使用进化算法对神经网络结构进行设计\upcite{DBLP:conf/icga/MillerTH89},也引发了之后的很多探索\upcite{koza1991genetic,DBLP:conf/nips/HarpSG89,DBLP:journals/compsys/Kitano90}。近些年,随着深度学习技术的发展,网络结构搜索技术在很多任务中受到关注。例如,网络结构搜索就很好的应用在语言建模上,并取得了很好的结果\upcite{DBLP:conf/iclr/LiuSY19,DBLP:conf/acl/LiHZXJXZLL20,DBLP:conf/emnlp/JiangHXZZ19}。下面将对网络结构搜索的基本方法和其在机器翻译中的应用进行介绍。
%---------------------------------------------------------------------------------------- %----------------------------------------------------------------------------------------
% NEW SUB-SECTION % NEW SUB-SECTION
...@@ -1106,7 +1104,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1106,7 +1104,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{eqnarray} \begin{eqnarray}
\hat{a} &=& \arg\max_{a}\sum_{i=1}^{n}{\funp{P}(\mathbi{y}_{i}|\mathbi{x}_{i};a)} \hat{a} &=& \arg\max_{a}\sum_{i=1}^{n}{\funp{P}(\mathbi{y}_{i}|\mathbi{x}_{i};a)}
\label{eq:15-54} \label{eq:15-57}
\end{eqnarray} \end{eqnarray}
\noindent 其中,$\funp{P}(\mathbi{y}_{i}|\mathbi{x}_{i};a)$为模型$a$观察到数据$\mathbi{x}_{i}$后预测$\mathbi{y}_{i}$的概率,而模型结构$a$本身可以看作是输入$\mathbi{x}$到输出$\mathbi{y}$ 的映射函数。图\ref{fig:15-29}展示了神经网络结构搜索方法的主要流程,其中包括三个部分:设计搜索空间、选择搜索策略以及进行性能评估,下面将对上述各个部分进行简要介绍。 \noindent 其中,$\funp{P}(\mathbi{y}_{i}|\mathbi{x}_{i};a)$为模型$a$观察到数据$\mathbi{x}_{i}$后预测$\mathbi{y}_{i}$的概率,而模型结构$a$本身可以看作是输入$\mathbi{x}$到输出$\mathbi{y}$ 的映射函数。图\ref{fig:15-29}展示了神经网络结构搜索方法的主要流程,其中包括三个部分:设计搜索空间、选择搜索策略以及进行性能评估,下面将对上述各个部分进行简要介绍。
...@@ -1141,9 +1139,9 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1141,9 +1139,9 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 整体框架:如图\ref{fig:15-30}所示,整体框架一般基于经验进行设计。比如,对于包括机器翻译在内的自然语言处理任务而言,一般会更倾向于使用循环神经网络或Transformer模型的相关结构作为搜索空间\upcite{DBLP:conf/icml/SoLL19,DBLP:conf/iclr/ZophL17,DBLP:conf/iclr/LiuSY19} \item {\small\bfnew{整体框架}}如图\ref{fig:15-30}所示,整体框架一般基于经验进行设计。比如,对于包括机器翻译在内的自然语言处理任务而言,一般会更倾向于使用循环神经网络或Transformer模型的相关结构作为搜索空间\upcite{DBLP:conf/icml/SoLL19,DBLP:conf/iclr/ZophL17,DBLP:conf/iclr/LiuSY19}
\vspace{0.5em} \vspace{0.5em}
\item 内部结构:对于内部结构的设计需要考虑到搜索过程中的最小搜索单元,以及搜索单元之间的连接方式。最小搜索单元指的是在结构搜索过程中可被选择的最小独立计算单元,在不同搜索空间的设计中,最小搜索单元的颗粒度各有不同,较小的搜索粒度主要包括如矩阵乘法、张量缩放等基本数学运算\upcite{DBLP:journals/corr/abs-2003-03384},更大粒度的搜索单元包括常见的激活函数以及一些局部结构,如ReLU、注意力机制等\upcite{DBLP:conf/acl/LiHZXJXZLL20,Chollet2017XceptionDL,DBLP:journals/taslp/FanTXQLL20}。不过,对于搜索颗粒度的问题,目前还缺乏有效的方法针对不同任务进行自动优化。 \item {\small\bfnew{内部结构}}对于内部结构的设计需要考虑到搜索过程中的最小搜索单元,以及搜索单元之间的连接方式。最小搜索单元指的是在结构搜索过程中可被选择的最小独立计算单元,在不同搜索空间的设计中,最小搜索单元的颗粒度各有不同,较小的搜索粒度主要包括如矩阵乘法、张量缩放等基本数学运算\upcite{DBLP:journals/corr/abs-2003-03384},更大粒度的搜索单元包括常见的激活函数以及一些局部结构,如ReLU、注意力机制等\upcite{DBLP:conf/acl/LiHZXJXZLL20,Chollet2017XceptionDL,DBLP:journals/taslp/FanTXQLL20}。不过,对于搜索颗粒度的问题,目前还缺乏有效的方法针对不同任务进行自动优化。
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
...@@ -1153,14 +1151,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1153,14 +1151,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsubsection{2. 搜索策略} \subsubsection{2. 搜索策略}
\parinterval 在定义好搜索空间之后,如何进行网络结构的搜索也同样重要。该过程被称为搜索策略的设计,其主要目的是根据已找到的模型结构计算出下一个最有潜力的模型结构,为保证模型有效性,在一些方法中也会引入外部知识(如经验性的模型结构或张量运算规则)对搜索过程进行剪枝。目前常见的搜索策略一般包括基于进化算法的方法、基于强化学习的方法、基于梯度的方法等方式 \parinterval 在定义好搜索空间之后,如何进行网络结构的搜索也同样重要。该过程被称为搜索策略的设计,其主要目的是根据已找到的模型结构计算出下一个最有潜力的模型结构,为保证模型有效性,在一些方法中也会引入外部知识(如经验性的模型结构或张量运算规则)对搜索过程进行剪枝。目前常见的搜索策略一般包括基于进化算法的方法、基于强化学习的方法以及基于梯度的方法等等
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 进化算法:进化算法最初被用来对神经网络模型结构以及权重参数进行优化\upcite{DBLP:conf/icga/MillerTH89,DBLP:journals/tnn/AngelineSP94,stanley2002evolving}。随着最优化算法的发展,近年来,对于网络参数的学习更多地采用梯度下降法的方式,但是进化算法仍被用于对模型结构进行优化\upcite{DBLP:conf/icml/RealMSSSTLK17,DBLP:conf/iclr/ElskenMH19,DBLP:conf/iclr/LiuSVFK18}。从结构优化的角度来说,一般是将模型结构看做遗传算法中种群的个体,使用轮盘赌或锦标赛等抽取方式,对种群中的结构进行取样作为亲本,之后通过亲本模型的突变产生新的模型结构,最终对这些新的模型结构进行适应度评估。根据模型结构在校验集上的性能确定是否将其加入种群。 \item {\small\bfnew{进化算法}}。进化算法最初被用来对神经网络模型结构、以及其中的权重参数进行优化\upcite{DBLP:conf/icga/MillerTH89,DBLP:journals/tnn/AngelineSP94,stanley2002evolving}。随着最优化算法的发展,近年来,对于网络参数的学习开始更多地采用梯度下降的方式,但是进化算法依旧被用于对模型结构进行优化\upcite{DBLP:conf/icml/RealMSSSTLK17,DBLP:conf/iclr/ElskenMH19,DBLP:conf/iclr/LiuSVFK18}。从结构优化的角度来说,一般是将模型结构看做遗传算法中种群的个体,使用轮盘赌或锦标赛等抽取方式,对种群中的结构进行取样作为亲本,之后通过亲本模型的突变产生新的模型结构,最终对这些新的模型结构进行适应度评估。根据模型结构在校验集上的性能确定是否将其加入种群。
\vspace{0.5em} \vspace{0.5em}
\item 强化学习:强化学习方法在{\chapterthirteen}已经进行了介绍,这里可以将神经网络结构的设计看做是一种序列生成任务,使用字符序列对网络结构进行表述\upcite{DBLP:conf/iclr/ZophL17}。这种方法的执行过程如图\ref{fig:15-33}所示。 \item {\small\bfnew{强化学习}}强化学习方法在{\chapterthirteen}已经进行了介绍,这里可以将神经网络结构的设计看做是一种序列生成任务,使用字符序列对网络结构进行表述\upcite{DBLP:conf/iclr/ZophL17}。这种方法的执行过程如图\ref{fig:15-33}所示。
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -1172,7 +1169,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1172,7 +1169,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
%------------------------------------------- %-------------------------------------------
\vspace{0.5em} \vspace{0.5em}
\item 基于梯度的方法:这种方法的思想是在连续空间中对模型结构进行表示\upcite{DBLP:conf/iclr/LiuSY19},通常将模型结构建模为超网络中的权重,使用基于梯度的优化方法对权重进行优化,最终达到归纳结构的目的,如图\ref{fig:15-34}所示。基于梯度的方法十分高效,因此也受到了很多关注\upcite{DBLP:conf/cvpr/WuDZWSWTVJK19,DBLP:conf/iclr/XuX0CQ0X20,DBLP:conf/acl/LiHZXJXZLL20} \item {\small\bfnew{基于梯度的方法}}这种方法的思想是在连续空间中对模型结构进行表示\upcite{DBLP:conf/iclr/LiuSY19},通常将模型结构建模为超网络中的权重,使用基于梯度的优化方法对权重进行优化,最终达到归纳结构的目的,如图\ref{fig:15-34}所示。基于梯度的方法十分高效,因此也受到了很多关注\upcite{DBLP:conf/cvpr/WuDZWSWTVJK19,DBLP:conf/iclr/XuX0CQ0X20,DBLP:conf/acl/LiHZXJXZLL20}
\vspace{0.5em} \vspace{0.5em}
%---------------------------------------------- %----------------------------------------------
...@@ -1192,15 +1189,15 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1192,15 +1189,15 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsubsection{3. 性能评估}\label{subsubsec-15.4.2.3} \subsubsection{3. 性能评估}\label{subsubsec-15.4.2.3}
\parinterval 由于结构搜索过程中会产生大量的中间结构,因此需要快速评估这些结构的性能优劣,以保证搜索中可以有效的挑选高质量的模型结构。有以下三方面问题需要考虑: \parinterval 由于结构搜索过程中会产生大量的中间结构,因此需要快速评估这些结构的性能优劣,以保证在搜索中可以有效地挑选高质量的模型结构。对于该问题,可以从以下三个方面来考虑:
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 数据以及超参数的调整:具体来说,可以用少量的数据训练模型,以便快速评估其性能\upcite{DBLP:conf/aistats/KleinFBHH17,DBLP:journals/corr/ChrabaszczLH17}。在超参数的调整方面,也可以通过减少模型训练轮数、减少模型的层数等方式来简化模型参数,达到加速训练、评估的目的\upcite{DBLP:conf/cvpr/ZophVSL18,Real2019AgingEF,DBLP:journals/corr/abs-1807-06906} \item {\small\bfnew{数据以及超参数的调整}}具体来说,可以用少量的数据训练模型,以便快速评估其性能\upcite{DBLP:conf/aistats/KleinFBHH17,DBLP:journals/corr/ChrabaszczLH17}。在超参数的调整方面,也可以通过减少模型训练轮数、减少模型的层数等方式来简化模型参数,达到加速训练、评估的目的\upcite{DBLP:conf/cvpr/ZophVSL18,Real2019AgingEF,DBLP:journals/corr/abs-1807-06906}
\vspace{0.5em} \vspace{0.5em}
\item 现有参数的继承及复用:另一类方法在现有的模型参数基础上,继续优化中间过程产生的模型结构,以加快待评价模型的收敛进程\upcite{DBLP:conf/icml/RealMSSSTLK17,DBLP:conf/iclr/ElskenMH19,DBLP:conf/aaai/CaiCZYW18}。这种方式无需从头训练搜索过程中间过程产生的模型结构,通过“热启动”的方式对模型参数进行优化,大幅减少性能评估过程的时间消耗。 \item {\small\bfnew{现有参数的继承及复用}}。通过在现有的模型参数基础上,继续优化中间过程产生的模型结构,来加快待评价模型的收敛进程\upcite{DBLP:conf/icml/RealMSSSTLK17,DBLP:conf/iclr/ElskenMH19,DBLP:conf/aaai/CaiCZYW18}。这种方式无需从头训练搜索过程中间过程产生的模型结构,通过“热启动”的方式对模型参数进行优化,能够大幅减少性能评估过程的时间消耗。
\vspace{0.5em} \vspace{0.5em}
\item 模型性能的预测:这种方式使用训练过程中的性能变化曲线来预估模型是否具有潜力,从而快速终止低性能模型的训练过程\upcite{DBLP:conf/ijcai/DomhanSH15,DBLP:conf/iclr/KleinFSH17,DBLP:conf/iclr/BakerGRN18} \item {\small\bfnew{模型性能的预测}}这种方式使用训练过程中的性能变化曲线来预估模型是否具有潜力,从而快速终止低性能模型的训练过程\upcite{DBLP:conf/ijcai/DomhanSH15,DBLP:conf/iclr/KleinFSH17,DBLP:conf/iclr/BakerGRN18}
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
...@@ -1210,7 +1207,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1210,7 +1207,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsection{机器翻译任务下的结构搜索} \subsection{机器翻译任务下的结构搜索}
\parinterval 对于自然语言处理的任务来说,网络结构搜索方法更多是在语言建模、命名实体识别等任务上进行的尝试\upcite{DBLP:conf/acl/LiHZXJXZLL20,DBLP:conf/emnlp/JiangHXZZ19}。其中,大多数工作是在基于循环神经网络的模型结构上进行探索,相较目前在机器翻译领域中广泛使用的Transformer模型结构来说,它们在性能上并没有体现出绝对优势。此外,由于机器翻译任务的复杂性,针对基于Transformer 的机器翻译模型的结构搜索方法会更少一些。不过仍有部分工作在机器翻译任务上取得了很好的表现。例如,在WMT19机器翻译比赛中,神经网络结构优化方法在多个任务上取得了很好的成绩\upcite{DBLP:conf/nips/LuoTQCL18,DBLP:conf/wmt/XiaTTGHCFGLLWWZ19}。对于结构搜索在机器翻译领域的应用目前主要包括两个方面,分别是对模型性能的改进以及模型效率的优化: \parinterval 对于自然语言处理任务来说,网络结构搜索方法更多是在语言建模、命名实体识别等任务上进行尝试\upcite{DBLP:conf/acl/LiHZXJXZLL20,DBLP:conf/emnlp/JiangHXZZ19}。其中,大多数工作是在基于循环神经网络的模型结构上进行探索的,相较于目前在机器翻译领域中广泛使用的Transformer模型结构来说,这些搜索到的结构在性能上并没有体现出绝对的优势。此外,由于机器翻译任务的复杂性,针对基于Transformer的机器翻译模型的结构搜索方法会更少一些。不过仍有部分工作在机器翻译任务上取得了很好的表现。例如,在WMT19机器翻译比赛中,神经网络结构优化方法在多个任务上取得了很好的成绩\upcite{DBLP:conf/nips/LuoTQCL18,DBLP:conf/wmt/XiaTTGHCFGLLWWZ19}。对于结构搜索在机器翻译领域的应用,目前主要包括两个方面:分别是对模型性能的改进以及模型效率的优化。
%---------------------------------------------------------------------------------------- %----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION % NEW SUBSUB-SECTION
...@@ -1222,23 +1219,20 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5} ...@@ -1222,23 +1219,20 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 搜索模型中的局部结构:在机器翻译任务中,一种典型的局部模型结构搜索方法是面向激活函数的搜索\upcite{DBLP:conf/iclr/RamachandranZL18},该方法将激活函数看作是一元、二元函数的若干次复合。例如,Swish 激活函数就是一种被找到的新的激活函数,如下: \item {\small\bfnew{搜索模型中的局部结构}}在机器翻译任务中,一种典型的局部模型结构搜索方法是面向激活函数的搜索\upcite{DBLP:conf/iclr/RamachandranZL18},该方法将激活函数看作是一元、二元函数的若干次复合。例如,Swish 激活函数就是一种被找到的新的激活函数,如下:
\begin{eqnarray} \begin{eqnarray}
f(x) &=& x \cdot \delta(\beta x) \\ f(x) &=& x \cdot \delta(\beta x) \\
\delta(z) &=& {(1 + \exp{(-z)})}^{-1} \delta(z) &=& {(1 + \exp{(-z)})}^{-1}
\label{eq:15-60} \label{eq:15-60}
\end{eqnarray} \end{eqnarray}
\noindent 相比于人工设计的激活函数ReLU而言,Swish函数在多个机器翻译任务取得了不错的效果。
\noindent 相比传统人工设计的激活函数ReLU而言,Swish函数在多个机器翻译任务取得了不错的效果。
\vspace{0.5em} \vspace{0.5em}
\item 搜索模型中局部结构的组合:在基于Transformer模型的网络结构搜索任务中,对于局部结构的组合方式的学习也受到了很多关注,其中包括基于进化算法的方法和基于梯度对现有Transformer模型结构进行改良\upcite{DBLP:conf/icml/SoLL19,DBLP:journals/taslp/FanTXQLL20}。与前文所述的对局部结构的改良不同,此处更多地是对现有经验性的局部结构进行组合,找到最佳的整体结构。在模型结构的表示方法上,这些方法会根据先验知识为搜索单元设定一个部分框架,如每当信息传递过来之后先进行层标准化,之后再对候选位置上的操作使用对应的搜索策略进行搜索。另外这类方法也会在Transformer结构中引入多分支结构,一个搜索单元的输出可以被多个后续单元所使用,这种方式有效扩大了结构搜索过程中的搜索空间,能够在现有Transformer结构的基础上找到更优的模型结构。 \item {\small\bfnew{搜索模型中局部结构的组合}}。在基于Transformer模型的网络结构搜索任务中,对于局部结构的组合方式的学习也受到了很多关注,其中包括基于进化算法的方法和基于梯度对现有Transformer模型结构的改良\upcite{DBLP:conf/icml/SoLL19,DBLP:journals/taslp/FanTXQLL20}。与前文所述的对局部结构的改良不同,此处更多地是对现有经验性的局部结构进行组合,找到最佳的整体结构。在模型结构的表示方法上,这些方法会根据先验知识为搜索单元设定一个部分框架,如每当信息传递过来之后先进行层标准化,之后再对候选位置上的操作使用对应的搜索策略进行搜索。另外这类方法也会在Transformer结构中引入多分支结构,一个搜索单元的输出可以被多个后续单元所使用,这种方式有效扩大了结构搜索过程中的搜索空间,能够在现有Transformer结构的基础上找到更优的模型结构。
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
\parinterval 此外对模型结构中超参数的自动搜索同样能够有效提升模型的性能\upcite{DBLP:journals/corr/abs-2009-02070},在机器翻译中也有应用\upcite{Li2020NeuralMT} \parinterval 此外对模型结构中超参数的自动搜索同样能够有效提升模型的性能\upcite{DBLP:journals/corr/abs-2009-02070}这种方法在机器翻译中也有应用\upcite{Li2020NeuralMT}
%---------------------------------------------------------------------------------------- %----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION % NEW SUBSUB-SECTION
...@@ -1246,14 +1240,13 @@ f(x) &=& x \cdot \delta(\beta x) \\ ...@@ -1246,14 +1240,13 @@ f(x) &=& x \cdot \delta(\beta x) \\
\subsubsection{2. 模型效率优化} \subsubsection{2. 模型效率优化}
\parinterval 除了能够提高机器翻译模型性能之外,网络结构搜索也能够优化模型的执行效率。从实用的角度出发,可以在进行结构搜索的同时考虑设备的计算能力,希望找到更适合运行设备的模型结构。同时也可以对大模型进行压缩,加速其在推断过程中的效率,这方面的工作不仅限于在机器翻译模型上,也有部分工作对基于注意力机制的预训练模型进行压缩。 \parinterval 网络结构搜索除了能够提高机器翻译模型性能之外,也能够优化模型的执行效率。从实用的角度出发,可以在进行结构搜索的同时考虑设备的计算能力,希望找到更适合运行设备的模型结构。同时,网络结构搜索也可以用来对大模型进行压缩,加速其在推断过程中的效率,这方面的工作不仅限于在机器翻译模型上,也有部分工作对基于注意力机制的预训练模型进行压缩。
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 面向特定设备的模型结构优化:可以在结构优化的过程中将设备的算力作为一个约束\upcite{DBLP:conf/acl/WangWLCZGH20}。具体来说,可以将搜索空间中各种结构建模在同一个超网络中,通过权重共享的方式进行训练。使用设备算力约束子模型,并通过进化算法对子模型进行搜索,搜索到适用于目标设备的模型结构。该方法搜索到的模型能够在保证模型性能不变前提下获得较大的效率提升。 \item {\small\bfnew{面向特定设备的模型结构优化}}。可以在结构优化的过程中将设备的算力作为一个约束\upcite{DBLP:conf/acl/WangWLCZGH20}。具体来说,可以将搜索空间中各种结构建模在同一个超网络中,通过权重共享的方式进行训练。使用设备算力约束子模型,并通过进化算法对子模型进行搜索,搜索到适用于目标设备的模型结构。该方法搜索到的模型能够在保证模型性能不变前提下获得较大的效率提升。
\vspace{0.5em} \vspace{0.5em}
\item 模型压缩:此外,在不考虑设备算力的情况下,也可以通过结构搜索方法对基于Transformer的预训练模型进行压缩。例如,将Transformer模型拆分为若干小组件,然后通过基于采样的结构搜索方法对压缩后的模型结构进行搜索,尝试找到最优且高效的推断模型\upcite{DBLP:journals/corr/abs-2008-06808}。类似的,也可以在基于BERT的预训练模型上通过结构搜索方法进行模型压缩,通过基于梯度的结构搜索方法,针对不同的下游任务将BERT模型压缩为小模型\upcite{DBLP:conf/ijcai/ChenLQWLDDHLZ20} \item {\small\bfnew{模型压缩}}此外,在不考虑设备算力的情况下,也可以通过结构搜索方法对基于Transformer的预训练模型进行压缩。例如,将Transformer模型拆分为若干小组件,然后通过基于采样的结构搜索方法对压缩后的模型结构进行搜索,尝试找到最优且高效的推断模型\upcite{DBLP:journals/corr/abs-2008-06808}。类似的,也可以在基于BERT的预训练模型上通过结构搜索方法进行模型压缩,通过基于梯度的结构搜索方法,针对不同的下游任务将BERT模型压缩为小模型\upcite{DBLP:conf/ijcai/ChenLQWLDDHLZ20}
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
...@@ -1268,18 +1261,18 @@ f(x) &=& x \cdot \delta(\beta x) \\ ...@@ -1268,18 +1261,18 @@ f(x) &=& x \cdot \delta(\beta x) \\
\sectionnewpage \sectionnewpage
\section{小结及拓展阅读} \section{小结及拓展阅读}
\parinterval 模型结构优化一直是机器翻译研究的重要方向。一方面,对于通用框架(如注意力机制)的结构改良可以服务于多种自然语言处理任务,另一方面,针对机器翻译的问题设计相适应的模型结构也是极具价值的。本章节重点介绍了神经机器翻译中结构优化的几种方法,内容涉及注意力机制的改进、深层神经网络的构建、句法结构的使用以及自动结构搜索等几个方面。此外,还有若干问题值得关注: \parinterval 模型结构优化一直是机器翻译研究的重要方向。一方面,对于通用框架(如注意力机制)的结构改良可以服务于多种自然语言处理任务,另一方面,针对机器翻译中存在的问题设计相适应的模型结构也是极具价值的。本章节重点介绍了神经机器翻译中几种结构优化方法,内容涉及注意力机制的改进、深层神经网络的构建、句法结构的使用以及自动结构搜索等几个方面。此外,还有若干问题值得关注:
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 多头注意力机制是近些年神经机器翻译中常用的结构。多头机制可以让模型从更多维度提取特征,也反应了一种多分支建模的思想。研究人员针对Transformer编码器的多头机制进行了分析,发现部分头在神经网络的学习过程中扮演至关重要的角色,并且蕴含语言学解释\upcite{DBLP:journals/corr/abs-1905-09418}。 而另一部分头本身则不具备很好的解释,对模型的帮助也不大,因此可以被剪枝掉。而且并不是头数越多,模型的性能就越强。此外也有研究人员发现,如果在训练过程中使用多头机制,并在推断过程中去除大部分头,模型性能不仅没有明显变化,还能够提高在CPU上的执行效率\upcite{Michel2019AreSH} \item 多头注意力是近些年神经机器翻译中常用的结构。多头机制可以让模型从更多维度提取特征,也反应了一种多分支建模的思想。研究人员针对Transformer编码器的多头机制进行了分析,发现部分头在神经网络的学习过程中扮演了至关重要的角色,并且蕴含语言学解释\upcite{DBLP:journals/corr/abs-1905-09418}。 而另一部分头本身则不具备很好的解释,对模型的帮助也不大,因此可以被剪枝掉。而且也有研究人员发现,在Transformer模型中并不是头数越多模型的性能就越强。如果在训练过程中使用多头机制,并在推断过程中去除大部分头,可以在模型性能不变的前提下提高模型在CPU上的执行效率\upcite{Michel2019AreSH}
\vspace{0.5em} \vspace{0.5em}
\item 此外,也可以利用正则化手段,在训练过程中增大不同头之间的差异\upcite{DBLP:conf/emnlp/LiTYLZ18}也可以引入多尺度的思想,对输入的特征进行分级表示,并引入短语的信息\upcite{DBLP:conf/emnlp/HaoWSZT19}。还可以通过对注意力权重进行调整,实现对序列中的实词与虚词进行区分\upcite{DBLP:conf/emnlp/Lin0RLS18}。 除了上述基于编码端-解码端的建模范式,还可以定义隐变量模型来捕获句子中潜在的语义信息\upcite{Su2018VariationalRN,DBLP:conf/acl/SetiawanSNP20},或直接对源语言和目标语言序列进行联合表示\upcite{Li2020NeuralMT} \item 此外,也可以利用正则化手段,在训练过程中增大不同头之间的差异\upcite{DBLP:conf/emnlp/LiTYLZ18}或引入多尺度的思想,对输入的特征进行分级表示,并引入短语的信息\upcite{DBLP:conf/emnlp/HaoWSZT19}。还可以通过对注意力权重进行调整,来区分序列中的实词与虚词\upcite{DBLP:conf/emnlp/Lin0RLS18}。除了上述基于编码器端-解码器端的建模范式,还可以定义隐变量模型来捕获句子中潜在的语义信息\upcite{Su2018VariationalRN,DBLP:conf/acl/SetiawanSNP20},或直接对源语言和目标语言序列进行联合表示\upcite{Li2020NeuralMT}
\vspace{0.5em} \vspace{0.5em}
\item Transformer等模型处理超长序列也是较为困难的。一种比较直接的解决办法是优化自注意力机制,降低模型计算复杂度。例如,采用基于滑动窗口的局部注意力的Longformer 模型\upcite{DBLP:journals/corr/abs-2004-05150}、基于随机特征的Performer\upcite{DBLP:journals/corr/abs-2006-04768}、使用低秩分解的Linformer\upcite{DBLP:journals/corr/abs-2009-14794}应用星型拓扑排序的Star-Transformer\upcite{DBLP:conf/naacl/GuoQLSXZ19} \item 对Transformer等模型来说,处理超长序列是较为困难的。一种比较直接的解决办法是优化自注意力机制,降低模型计算复杂度。例如,采用了基于滑动窗口的局部注意力的Longformer模型\upcite{DBLP:journals/corr/abs-2004-05150}、基于随机特征的Performer\upcite{DBLP:journals/corr/abs-2006-04768}、使用低秩分解的Linformer\upcite{DBLP:journals/corr/abs-2009-14794}应用星型拓扑排序的Star-Transformer\upcite{DBLP:conf/naacl/GuoQLSXZ19}
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
\subsection{篇章级翻译的挑战} \subsection{篇章级翻译的挑战}
\parinterval “篇章”在这里是指一系列连续的段落或句子所构成的整体,其中各个句子间从形式和内容上都具有一定的连贯性和一致性\upcite{jurafsky2000speech}。这些联系主要体现在{\small\sffamily\bfseries{衔接}}\index{衔接}(Cohesion \index{Cohesion}以及连贯两个方面。其中衔接体现在显性的语言成分和结构上,包括篇章中句子间的语法和词汇的联系,而连贯体现在各个句子之间的逻辑和语义的联系上。因此,篇章级翻译就是要将这些上下文之间的联系考虑在内,从而生成比句子级翻译更连贯和准确的翻译结果。实例\ref{eg:17-1}就展示了一个使用篇章信息进行机器翻译的实例。 \parinterval “篇章”在这里是指一系列连续的段落或句子所构成的整体,其中各个句子间从形式和内容上都具有一定的连贯性和一致性\upcite{jurafsky2000speech}。这些联系主要体现在衔接以及连贯两个方面。其中衔接体现在显性的语言成分和结构上,包括篇章中句子间的语法和词汇的联系,而连贯体现在各个句子之间的逻辑和语义的联系上。因此,篇章级翻译就是要将这些上下文之间的联系考虑在内,从而生成比句子级翻译更连贯和准确的翻译结果。实例\ref{eg:17-1}就展示了一个使用篇章信息进行机器翻译的实例。
\begin{example} \begin{example}
上下文句子:我/上周/针对/这个/问题/做出/解释/并/咨询/了/他的/意见/。 上下文句子:我/上周/针对/这个/问题/做出/解释/并/咨询/了/他的/意见/。
...@@ -450,7 +450,7 @@ ...@@ -450,7 +450,7 @@
\parinterval 不过由于不同语言的特性多种多样,上下文信息在篇章级翻译中的作用也不尽相同。比如,在德语中名词是分词性的,因此在代词翻译的过程中需要根据其先行词的词性进行区分,而这种现象在其它不区分名词词性的语言中是不存在的。这意味着篇章级翻译在不同的语种中可能对应不同的上下文现象。 \parinterval 不过由于不同语言的特性多种多样,上下文信息在篇章级翻译中的作用也不尽相同。比如,在德语中名词是分词性的,因此在代词翻译的过程中需要根据其先行词的词性进行区分,而这种现象在其它不区分名词词性的语言中是不存在的。这意味着篇章级翻译在不同的语种中可能对应不同的上下文现象。
\parinterval 正是由于这种上下文现象的多样性,使评价篇章级翻译模型的性能变得相对困难。目前篇章级机器翻译主要针对一些常见的上下文现象进行优化,比如代词翻译、省略、连接和词汇衔接等,而{\chapterfour}介绍的BLEU等通用自动评价指标通常对这些上下文依赖现象不敏感,因此篇章级翻译需要采用一些专用方法来对这些具体现象进行评价。 \parinterval 正是这种上下文现象的多样性,使评价篇章级翻译模型的性能变得相对困难。目前篇章级机器翻译主要针对一些常见的上下文现象进行优化,比如代词翻译、省略、连接和词汇衔接等,而{\chapterfour}介绍的BLEU等通用自动评价指标通常对这些上下文依赖现象不敏感,因此篇章级翻译需要采用一些专用方法来对这些具体现象进行评价。
\parinterval 在统计机器翻译时代就已经有大量的研究工作专注于篇章信息的建模,这些工作大多针对某一具体的上下文现象,比如,篇章结构\upcite{DBLP:conf/anlp/MarcuCW00,foster2010translating,DBLP:conf/eacl/LouisW14}、代词回指\upcite{DBLP:conf/iwslt/HardmeierF10,DBLP:conf/wmt/NagardK10,DBLP:conf/eamt/LuongP16,}、词汇衔接\upcite{tiedemann2010context,DBLP:conf/emnlp/GongZZ11,DBLP:conf/ijcai/XiongBZLL13,xiao2011document}和篇章连接词\upcite{DBLP:conf/sigdial/MeyerPZC11,DBLP:conf/hytra/MeyerP12,}等。区别于篇章级统计机器翻译,篇章级神经机器翻译不需要针对某一具体的上下文现象构造相应的特征,而是通过翻译模型本身从上下文句子中抽取和融合的上下文信息。通常情况下,篇章级机器翻译可以采用局部建模的手段将前一句或者周围几句作为上下文送入模型。针对需要长距离上下文的情况,也可以使用全局建模的手段直接从篇章的所有句子中提取上下文信息。近几年多数研究工作都在探索更有效的局部建模或全局建模方法,主要包括改进输入\upcite{DBLP:conf/discomt/TiedemannS17,DBLP:conf/naacl/BawdenSBH18,DBLP:conf/wmt/GonzalesMS17,DBLP:journals/corr/abs-1910-07481}、多编码器结构\upcite{DBLP:journals/corr/JeanLFC17,DBLP:journals/corr/abs-1805-10163,DBLP:conf/emnlp/ZhangLSZXZL18}、层次结构\upcite{DBLP:conf/naacl/MarufMH19,DBLP:conf/acl/HaffariM18,DBLP:conf/emnlp/YangZMGFZ19,DBLP:conf/ijcai/ZhengYHCB20}以及基于缓存的方法\upcite{DBLP:conf/coling/KuangXLZ18,DBLP:journals/tacl/TuLSZ18}等。 \parinterval 在统计机器翻译时代就已经有大量的研究工作专注于篇章信息的建模,这些工作大多针对某一具体的上下文现象,比如,篇章结构\upcite{DBLP:conf/anlp/MarcuCW00,foster2010translating,DBLP:conf/eacl/LouisW14}、代词回指\upcite{DBLP:conf/iwslt/HardmeierF10,DBLP:conf/wmt/NagardK10,DBLP:conf/eamt/LuongP16,}、词汇衔接\upcite{tiedemann2010context,DBLP:conf/emnlp/GongZZ11,DBLP:conf/ijcai/XiongBZLL13,xiao2011document}和篇章连接词\upcite{DBLP:conf/sigdial/MeyerPZC11,DBLP:conf/hytra/MeyerP12,}等。区别于篇章级统计机器翻译,篇章级神经机器翻译不需要针对某一具体的上下文现象构造相应的特征,而是通过翻译模型本身从上下文句子中抽取和融合的上下文信息。通常情况下,篇章级机器翻译可以采用局部建模的手段将前一句或者周围几句作为上下文送入模型。针对需要长距离上下文的情况,也可以使用全局建模的手段直接从篇章的所有句子中提取上下文信息。近几年多数研究工作都在探索更有效的局部建模或全局建模方法,主要包括改进输入\upcite{DBLP:conf/discomt/TiedemannS17,DBLP:conf/naacl/BawdenSBH18,DBLP:conf/wmt/GonzalesMS17,DBLP:journals/corr/abs-1910-07481}、多编码器结构\upcite{DBLP:journals/corr/JeanLFC17,DBLP:journals/corr/abs-1805-10163,DBLP:conf/emnlp/ZhangLSZXZL18}、层次结构\upcite{DBLP:conf/naacl/MarufMH19,DBLP:conf/acl/HaffariM18,DBLP:conf/emnlp/YangZMGFZ19,DBLP:conf/ijcai/ZhengYHCB20}以及基于缓存的方法\upcite{DBLP:conf/coling/KuangXLZ18,DBLP:journals/tacl/TuLSZ18}等。
...@@ -474,7 +474,7 @@ ...@@ -474,7 +474,7 @@
\subsection{篇章级翻译的建模} \subsection{篇章级翻译的建模}
\parinterval 在理想情况下,篇章级翻译应该以整个篇章为单位作为模型的输入和输出。然而由于现实中篇章对应的序列过长,因此直接建模整个篇章的词序列难度很大,这使得主流的序列到序列模型很难直接使用。一种思路是采用能够处理超长序列的模型对篇章序列建模,比如,使用{\chapterfifteen}中提到的处理长序列的Transformer模型就是一种的解决方法\upcite{Kitaev2020ReformerTE}。不过,这类模型并不针对篇章级翻译的具体问题,因此并不是篇章级翻译中的主流方法。 \parinterval 在理想情况下,篇章级翻译应该以整个篇章为单位作为模型的输入和输出。然而由于现实中篇章对应的序列过长,因此直接建模整个篇章序列难度很大,这使得主流的序列到序列模型很难直接使用。一种思路是采用能够处理超长序列的模型对篇章序列建模,比如,使用{\chapterfifteen}中提到的处理长序列的Transformer模型就是一种的解决方法\upcite{Kitaev2020ReformerTE}。不过,这类模型并不针对篇章级翻译的具体问题,因此并不是篇章级翻译中的主流方法。
\parinterval 现在常见的端到端做法还是从句子级翻译出发,通过额外的模块来对篇章中的上下文句子进行表示,然后提取相应的上下文信息并融入到当前句子的翻译过程中。形式上,篇章级翻译的建模方式如下: \parinterval 现在常见的端到端做法还是从句子级翻译出发,通过额外的模块来对篇章中的上下文句子进行表示,然后提取相应的上下文信息并融入到当前句子的翻译过程中。形式上,篇章级翻译的建模方式如下:
\begin{eqnarray} \begin{eqnarray}
...@@ -519,17 +519,17 @@ ...@@ -519,17 +519,17 @@
\subsubsection{2. 多编码器结构} \subsubsection{2. 多编码器结构}
\parinterval 另一种思路是对传统的编码器-解码器框架进行更改,引入额外的编码器来对上下文句子进行编码,该结构被称为多编码器结构\upcite{DBLP:conf/acl/LiLWJXZLL20,DBLP:conf/discomt/SugiyamaY19}。这种结构最早被应用在基于循环神经网络的篇章级翻译模型中\upcite{DBLP:journals/corr/JeanLFC17,DBLP:conf/coling/KuangX18,DBLP:conf/naacl/BawdenSBH18,DBLP:conf/pacling/YamagishiK19},后期证明在Transformer模型上同样适用\upcite{DBLP:journals/corr/abs-1805-10163,DBLP:conf/emnlp/ZhangLSZXZL18}。图\ref{fig:17-18}展示了一个基于Transformer模型的多编码器结构,基于源语言当前待翻译句子的编码表示$\mathbi{h}$和上下文句子的编码表示$\mathbi{h}^{\textrm pre}$,模型首先通过注意力机制提取句子间上下文信息$\mathbi{d}$ \parinterval 另一种思路是对传统的编码器-解码器框架进行更改,引入额外的编码器来对上下文句子进行编码,该结构被称为多编码器结构\upcite{DBLP:conf/acl/LiLWJXZLL20,DBLP:conf/discomt/SugiyamaY19}。这种结构最早被应用在基于循环神经网络的篇章级翻译模型中\upcite{DBLP:journals/corr/JeanLFC17,DBLP:conf/coling/KuangX18,DBLP:conf/naacl/BawdenSBH18,DBLP:conf/pacling/YamagishiK19},后期证明在Transformer模型上同样适用\upcite{DBLP:journals/corr/abs-1805-10163,DBLP:conf/emnlp/ZhangLSZXZL18}。图\ref{fig:17-18}展示了一个基于Transformer模型的多编码器结构,基于源语言当前待翻译句子的编码表示$\mathbi{h}$和上下文句子的编码表示$\mathbi{h}^{\textrm {pre}}$,模型首先通过注意力机制提取句子间上下文信息$\mathbi{d}$
\begin{eqnarray} \begin{eqnarray}
\mathbi{d}&=&\textrm{Attention}(\mathbi{h},\mathbi{h}^{\textrm pre},\mathbi{h}^{\textrm pre}) \mathbi{d}&=&\textrm{Attention}(\mathbi{h},\mathbi{h}^{\textrm {pre}},\mathbi{h}^{\textrm {pre}})
\label{eq:17-3-3} \label{eq:17-3-3}
\end{eqnarray} \end{eqnarray}
其中,$\mathbi{h}$作为Query(查询),$\mathbi{h}^{\textrm pre}$作为Key(键)和Value(值)。然后通过门控机制将待翻译句子中每个位置的编码表示和该位置对应的上下文信息进行融合,具体方式如下: 其中,$\mathbi{h}$作为Query(查询),$\mathbi{h}^{\textrm pre}$作为Key(键)和Value(值)。然后通过门控机制将待翻译句子中每个位置的编码表示和该位置对应的上下文信息进行融合,具体方式如下:
\begin{eqnarray} \begin{eqnarray}
\widetilde{\mathbi{h}_{t}}&=&\lambda_{t}\mathbi{h}_{t}+(1-\lambda_{t})\mathbi{d}_{t}
\label{eq:17-3-4}\\
\lambda_{t}&=&\sigma(\mathbi{W}_{\lambda}[\mathbi{h}_{t};\mathbi{d}_{t}]+\mathbi{b}_{\lambda}) \lambda_{t}&=&\sigma(\mathbi{W}_{\lambda}[\mathbi{h}_{t};\mathbi{d}_{t}]+\mathbi{b}_{\lambda})
\label{eq:17-3-5} \label{eq:17-3-5}\\
\widetilde{\mathbi{h}_{t}}&=&\lambda_{t}\mathbi{h}_{t}+(1-\lambda_{t})\mathbi{d}_{t}
\label{eq:17-3-4}
\end{eqnarray} \end{eqnarray}
其中,$\widetilde{\mathbi{h}}$为融合了上下文信息的最终序列表示结果,$\widetilde{\mathbi{h}_{t}}$为其第$t$个位置的表示。$\mathbi{W}_{\lambda}$$\mathbi{b}_{\lambda}$为模型可学习的参数,$\sigma$为Sigmoid函数,用来获取门控权值$\lambda$。除了在编码端融合源语言上下文信息,也可以直接用类似机制在解码器内完成源语言上下文信息的融合\upcite{DBLP:conf/emnlp/ZhangLSZXZL18} 其中,$\widetilde{\mathbi{h}}$为融合了上下文信息的最终序列表示结果,$\widetilde{\mathbi{h}_{t}}$为其第$t$个位置的表示。$\mathbi{W}_{\lambda}$$\mathbi{b}_{\lambda}$为模型可学习的参数,$\sigma$为Sigmoid函数,用来获取门控权值$\lambda$。除了在编码端融合源语言上下文信息,也可以直接用类似机制在解码器内完成源语言上下文信息的融合\upcite{DBLP:conf/emnlp/ZhangLSZXZL18}
...@@ -553,7 +553,7 @@ ...@@ -553,7 +553,7 @@
\parinterval 多编码器结构通过额外的编码器对前一句进行编码,但是当处理更多上下文句子的时候仍然面临效率低下的问题。为了捕捉更大范围的上下文,可以采用层次结构来对更多的上下文句子进行建模。层次结构是一种有效的序列表示方法,而且人类语言中天然就具有层次性,比如,句法树、篇章结构树等。类似的思想也成功的应用在基于树的句子级翻译模型中(见{\chaptereight}{\chapterfifteen})。 \parinterval 多编码器结构通过额外的编码器对前一句进行编码,但是当处理更多上下文句子的时候仍然面临效率低下的问题。为了捕捉更大范围的上下文,可以采用层次结构来对更多的上下文句子进行建模。层次结构是一种有效的序列表示方法,而且人类语言中天然就具有层次性,比如,句法树、篇章结构树等。类似的思想也成功的应用在基于树的句子级翻译模型中(见{\chaptereight}{\chapterfifteen})。
\parinterval\ref{fig:17-19}描述了一个基于层次注意力的模型结构\upcite{Werlen2018DocumentLevelNM}。首先通过翻译模型的编码器获取前$K$个句子的词序列编码表示$(\mathbi{h}^{\textrm{pre}1},\dots,\mathbi{h}^{\textrm{pre}K})$,然后针对前文每个句子的词序列编码表示$\mathbi{h}^{\textrm{pre}k}$,使用词级注意力提取句子级的上下文信息$\mathbi{s}^{k}$,然后在这$K$个句子级上下文信息$\mathbi{s}=(\mathbi{s}^1,\dots,\mathbi{s}^K)$的基础上,使用句子级注意力提取篇章上下文信息$\mathbi{d}$。由于上下文信息$\mathbi{d}$的获取涉及到词级和句子级两个不同层次的注意力操作,因此将该过程称为层次注意力。实际上,这种方法并没有使用语言学的篇章层次结构。但是,句子级注意力在归纳统计意义上的篇章结构,因此这种方法也可以捕捉不同句子之间的关系。 \parinterval\ref{fig:17-19}描述了一个基于层次注意力的模型结构\upcite{Werlen2018DocumentLevelNM}。首先通过翻译模型的编码器获取前$K$个句子的词序列编码表示$(\mathbi{h}^{\textrm{pre}1},\dots,\mathbi{h}^{\textrm{pre}K})$,然后针对前文每个句子的词序列编码表示$\mathbi{h}^{\textrm{pre}k}$,使用词级注意力提取当前句子内部的注意力信息$\mathbi{s}^{k}$,然后在这$K$个句子级上下文信息$\mathbi{s}=(\mathbi{s}^1,\dots,\mathbi{s}^K)$的基础上,使用句子级注意力提取篇章上下文信息$\mathbi{d}$。由于上下文信息$\mathbi{d}$的获取涉及到词级和句子级两个不同层次的注意力操作,因此将该过程称为层次注意力。实际上,这种方法并没有使用语言学的篇章层次结构。但是,句子级注意力在归纳统计意义上的篇章结构,因此这种方法也可以捕捉不同句子之间的关系。
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -564,12 +564,12 @@ ...@@ -564,12 +564,12 @@
\end{figure} \end{figure}
%---------------------------------------------- %----------------------------------------------
\parinterval 为了增强模型的表示能力,层次注意力中并未直接使用当前句子第$t$个位置的编码表示$\mathbi{h}_{t}$作为查询,而是通过$f_w$$f_s$两个线性变换分别获取词级注意力和句子级注意力的查询$\mathbi{q}_{w}$$\mathbi{q}_{s}$,定义如下: \parinterval 为了增强模型的表示能力,层次注意力中并未直接使用当前句子第$t$个位置的编码表示$\mathbi{h}_{t}$作为查询,而是通过两个线性变换分别获取词级注意力和句子级注意力的查询$\mathbi{q}_{w}$$\mathbi{q}_{s}$,定义如公式\eqref{eq:17-3-6}\eqref{eq:17-3-8},其中${\mathbi W}_w$${\mathbi W}_s$${\mathbi b}_w$${\mathbi b}_s$分别是两个线性变换的权重和偏置。
\begin{eqnarray} \begin{eqnarray}
\mathbi{q}_{w}&=&f_w(\mathbi{h}_t) \mathbi{q}_{w}&=&{\mathbi W}_w \mathbi{h}_t+{\mathbi b}_w
\label{eq:17-3-6}\\ \label{eq:17-3-6}\\
\mathbi{q}_{s}&=&f_s(\mathbi{h}_t) \mathbi{q}_{s}&=&{\mathbi W}_s \mathbi{h}_t+{\mathbi b}_s
\label{eq:17-3-8} \label{eq:17-3-8}
\end{eqnarray} \end{eqnarray}
...@@ -622,7 +622,7 @@ ...@@ -622,7 +622,7 @@
\parinterval 在句子级翻译模型中引入目标语言端的篇章级语言模型是一种结合上下文信息的常用手段\upcite{DBLP:conf/discomt/GarciaCE19,DBLP:journals/tacl/YuSSLKBD20,DBLP:journals/corr/abs-2010-12827}。 相比于篇章级双语数据,篇章级单语数据更容易获取。在双语数据稀缺的情况下,通过引入目标语言端的篇章级语言模型可以更充分的利用这些单语数据,比如,可以把这个语言模型与翻译模型做插值,也可以将其作为重排序阶段的一种特征。 \parinterval 在句子级翻译模型中引入目标语言端的篇章级语言模型是一种结合上下文信息的常用手段\upcite{DBLP:conf/discomt/GarciaCE19,DBLP:journals/tacl/YuSSLKBD20,DBLP:journals/corr/abs-2010-12827}。 相比于篇章级双语数据,篇章级单语数据更容易获取。在双语数据稀缺的情况下,通过引入目标语言端的篇章级语言模型可以更充分的利用这些单语数据,比如,可以把这个语言模型与翻译模型做插值,也可以将其作为重排序阶段的一种特征。
\parinterval 另一种方法是两阶段翻译。这种方法不影响句子级翻译模型的推断过程,而是在完成翻译后使用额外的模块进行第二阶段的翻译\upcite{DBLP:conf/aaai/XiongH0W19,DBLP:conf/acl/VoitaST19}。如图\ref{fig:17-21}所示,这种两阶段翻译的做法相当于将篇章级翻译的问题进行了分离和简化,适用于篇章级双语数据稀缺的场景两阶段翻译。基于类似的思想,也可以使用后编辑的做法对翻译结果进行修正。区别于两阶段翻译的方法,后编辑的方法无需参考源语言信息,只是对译文结果进行修正\upcite{DBLP:conf/emnlp/VoitaST19} \parinterval 另一种方法是两阶段翻译。这种方法不影响句子级翻译模型的推断过程,而是在完成翻译后使用额外的模块进行第二阶段的翻译\upcite{DBLP:conf/aaai/XiongH0W19,DBLP:conf/acl/VoitaST19}。如图\ref{fig:17-21}所示,这种两阶段翻译的做法相当于将篇章级翻译的问题进行了分离和简化:在第一阶段翻译中使用句子级翻译模型完成对篇章中某个句子的翻译,为了进一步地引入篇章上下文信息,第二阶段的翻译过程在第一阶段翻译结果的基础上,利用两次注意力操作,融合并引入源语言和目标语言的篇章上下文信息和当前句子信息。该方法适用于篇章级双语数据稀缺的场景。基于类似的思想,也可以使用后编辑的做法对翻译结果进行修正。区别于两阶段翻译的方法,后编辑的方法无需参考源语言信息,只是对译文结果进行修正\upcite{DBLP:conf/emnlp/VoitaST19}
%---------------------------------------------- %----------------------------------------------
\begin{figure}[htp] \begin{figure}[htp]
...@@ -641,19 +641,16 @@ ...@@ -641,19 +641,16 @@
\parinterval 使用更大上下文进行机器翻译建模是极具潜力的研究方向,包括多模态翻译在内的多个领域也非常活跃。有许多问题值得进一步思考与讨论: \parinterval 使用更大上下文进行机器翻译建模是极具潜力的研究方向,包括多模态翻译在内的多个领域也非常活跃。有许多问题值得进一步思考与讨论:
\begin{itemize} \begin{itemize}
\vspace{0.5em} \vspace{0.5em}
\item 本章仅对音频处理和语音识别进行了简单的介绍,具体内容可以参考一些经典书籍,比如关于信号处理的基础知识\upcite{Oppenheim2001DiscretetimeSP,Quatieri2001DiscreteTimeSS},以及语音识别的传统方法\upcite{DBLP:books/daglib/0071550,Huang2001SpokenLP}和基于深度学习的最新方法\upcite{benesty2008automatic} \item 本章仅对音频处理和语音识别进行了简单的介绍,具体内容可以参考一些经典书籍,比如关于信号处理的基础知识\upcite{Oppenheim2001DiscretetimeSP,Quatieri2001DiscreteTimeSS},以及语音识别的传统方法\upcite{DBLP:books/daglib/0071550,Huang2001SpokenLP}和基于深度学习的最新方法\upcite{benesty2008automatic}
\vspace{0.5em} \vspace{0.5em}
\item 此外,语音翻译的一个重要应用是机器同声传译。机器同声传译的一个难点在于不同语言的文字顺序不同。目前,同声传译的一种思路是基于目前已经说出的语音进行翻译\upcite{DBLP:conf/acl/MaHXZLZZHLLWW19},比如,等待源语$k$个词语,然后再进行翻译,同时改进束搜索方式来预测未来的词序列,从而提升准确度\upcite{DBLP:conf/emnlp/ZhengMZH19}。或者,对当前语音进行翻译,但需要判断翻译的词是否能够作为最终结果,已决定是否根据之后的语音重新进行翻译\upcite{DBLP:conf/naacl/DalviDSV18,DBLP:journals/corr/ChoE16}。第二种思路是动态预测当前时刻是应该继续等待还是开始翻译,这种方式更符合人类进行同传的行为。但是这种策略的难点在于标注每一时刻的决策状态十分耗时且标准难以统一,目前主流的方式是利用强化学习方法\upcite{DBLP:conf/eacl/NeubigCGL17,DBLP:conf/emnlp/GrissomHBMD14},对句子进行不同决策方案采样,最终学到最优的决策方案。此外,还有一些工作设计不同的学习策略\upcite{DBLP:conf/acl/ZhengLZMLH20,DBLP:conf/emnlp/ZhengZMH19,DBLP:conf/acl/ZhengZMH19}或改进注意力机制\upcite{DBLP:conf/acl/ArivazhaganCMCY19}以提升机器同声传译的性能。 \item 此外,语音翻译的一个重要应用是机器同声传译。机器同声传译的一个难点在于不同语言的文字顺序不同。目前,同声传译的一种思路是基于目前已经说出的语音进行翻译\upcite{DBLP:conf/acl/MaHXZLZZHLLWW19},比如,等待源语$k$个词语,然后再进行翻译,同时改进束搜索方式来预测未来的词序列,从而提升准确度\upcite{DBLP:conf/emnlp/ZhengMZH19}。或者,对当前语音进行翻译,但需要判断翻译的词是否能够作为最终结果,已决定是否根据之后的语音重新进行翻译\upcite{DBLP:conf/naacl/DalviDSV18,DBLP:journals/corr/ChoE16}。第二种思路是动态预测当前时刻是应该继续等待还是开始翻译,这种方式更符合人类进行同传的行为。但是这种策略的难点在于标注每一时刻的决策状态十分耗时且标准难以统一,目前主流的方式是利用强化学习方法\upcite{DBLP:conf/eacl/NeubigCGL17,DBLP:conf/emnlp/GrissomHBMD14},对句子进行不同决策方案采样,最终学到最优的决策方案。此外,还有一些工作设计不同的学习策略\upcite{DBLP:conf/acl/ZhengLZMLH20,DBLP:conf/emnlp/ZhengZMH19,DBLP:conf/acl/ZhengZMH19}或改进注意力机制\upcite{DBLP:conf/acl/ArivazhaganCMCY19}以提升机器同声传译的性能。
\vspace{0.5em}
\item 在篇章级翻译方面,一些研究工作对这类模型的上下文建模能力进行了探索\upcite{DBLP:conf/discomt/KimTN19,DBLP:conf/acl/LiLWJXZLL20},发现模型性能在小数据集上的BLEU提升并不完全来自于上下文信息的利用。同时,受限于数据规模,篇章级翻译模型相对难以训练。一些研究人员通过调整训练策略使得模型更容易捕获上下文信息\upcite{DBLP:journals/corr/abs-1903-04715,DBLP:conf/acl/SaundersSB20,DBLP:conf/mtsummit/StojanovskiF19}。除了训练策略的调整,也可以使用数据增强和预训练的手段来缓解数据稀缺的问题\upcite{DBLP:conf/discomt/SugiyamaY19,DBLP:journals/corr/abs-1911-03110,DBLP:journals/corr/abs-2001-08210}。此外,区别于传统的篇章级翻译,一些对话翻译也需要使用长距离上下文信息\upcite{DBLP:conf/wmt/MarufMH18}
\vspace{0.5em} \vspace{0.5em}
\item 此外,多模态机器翻译、图像描述生成、视觉问答等多模态任务受到广泛关注。如何将多个模态的信息充分融合,是研究多模态任务的重要问题。另外,数据稀缺是大多数多模态任务的瓶颈之一,可以采取数据增强的方式缓解\upcite{DBLP:conf/emnlp/GokhaleBBY20,DBLP:conf/eccv/Tang0ZWY20}。但是,这时仍需要回答在:模型没有充分训练时,图像等模态信息究竟在翻译里发挥了多少作用?类似的问题在篇章级机器翻译中也存在,上下文模型在训练数据量很小的时候对翻译的作用十分微弱\upcite{DBLP:conf/acl/LiLWJXZLL20}。此外,受到预训练模型的启发,在多模态信息处理中,图像和文本联合预训练的工作也相继开展\upcite{DBLP:conf/eccv/Li0LZHZWH0WCG20,DBLP:conf/aaai/ZhouPZHCG20,DBLP:conf/iclr/SuZCLLWD20} %\item 在篇章级翻译方面,一些研究工作对这类模型的上下文建模能力进行了探索\upcite{DBLP:conf/discomt/KimTN19,DBLP:conf/acl/LiLWJXZLL20},发现模型性能在小数据集上的BLEU提升并不完全来自于上下文信息的利用。同时,受限于数据规模,篇章级翻译模型相对难以训练。一些研究人员通过调。除了训练策略的调整,也可以使用数据增强和预训练的手段来缓解数据稀缺的问题\upcite{DBLP:conf/discomt/SugiyamaY19,DBLP:journals/corr/abs-1911-03110,DBLP:journals/corr/abs-2001-08210}。此外,区别于传统的篇章级翻译,一些对话翻译也需要使用长距离上下文信息\upcite{DBLP:conf/wmt/MarufMH18}。
%\vspace{0.5em}
%\item 此外,多模态机器翻译、图像描述生成、视觉问答等多模态任务受到广泛关注。如何将多个模态的信息充分融合,是研究多模态任务的重要问题。另外,数据稀缺是大多数多模态任务的瓶颈之一,可以采取数据增强的方式缓解\upcite{DBLP:conf/emnlp/GokhaleBBY20,DBLP:conf/eccv/Tang0ZWY20}。但是,这时仍需要回答在:模型没有充分训练时,图像等模态信息究竟在翻译里发挥了多少作用?类似的问题在篇章级机器翻译中也存在,上下文模型在训练数据量很小的时候对翻译的作用十分微弱\upcite{DBLP:conf/acl/LiLWJXZLL20}。此外,受到预训练模型的启发,在多模态信息处理中,图像和文本联合预训练的工作也相继开展\upcite{DBLP:conf/eccv/Li0LZHZWH0WCG20,DBLP:conf/aaai/ZhouPZHCG20,DBLP:conf/iclr/SuZCLLWD20}。
%\vspace{0.5em}
\item {\red 这段有问题!周一确认。}在多模态机器翻译任务和篇章级机器翻译任务中,数据规模往往受限,导致模型训练困难,很难取得较好的性能。比如在篇章级机器翻译中,一些研究工作对这类模型的上下文建模能力进行了探索\upcite{DBLP:conf/discomt/KimTN19,DBLP:conf/acl/LiLWJXZLL20},发现模型性能在小数据集上的BLEU提升并不完全来自于对上下文信息的利用,针对这个问题一些研究人员通过调整训练策略使得模型更容易捕获上下文信息\upcite{DBLP:journals/corr/abs-1903-04715,DBLP:conf/acl/SaundersSB20,DBLP:conf/mtsummit/StojanovskiF19}。除了训练策略的调整,也可以使用数据增强的方式(例如,构造伪数据)来提升整体数据量\upcite{DBLP:conf/emnlp/GokhaleBBY20,DBLP:conf/eccv/Tang0ZWY20,DBLP:conf/discomt/SugiyamaY19},或者使用预训练的手段来利用额外地单语或图像数据\upcite{DBLP:conf/aaai/ZhouPZHCG20,DBLP:conf/iclr/SuZCLLWD20,DBLP:journals/corr/abs-1911-03110}
\vspace{0.5em} \vspace{0.5em}
\end{itemize} \end{itemize}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论