Commit ae21cc86 by 孟霞

合并分支 'caorunzhe' 到 'mengxia'

Caorunzhe

查看合并请求 !926
parents 6273cf64 d0a5d0f2
......@@ -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,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,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) {聚合网络};
......
......@@ -2,10 +2,10 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=green!20]
\tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=3em,rounded corners=5pt,fill=red!20]
\tikzstyle{fnoder}=[rectangle,inner sep=0mm,minimum height=2.4em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,red!40]
\tikzstyle{fnodeg}=[rectangle,inner sep=0mm,minimum height=2.4em,minimum width=6.8em,draw,dashed,very thick,rounded corners=5pt,green!40]
\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!30,draw,thick]
\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=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=west,hnode] (n1) at ([xshift=0.2em,yshift=0em]f1.west) {$\mathbi{h}_1^{\textrm{up}}$};
......
\begin{tikzpicture}
\tikzstyle{unit}=[draw,rounded corners=2pt,drop shadow,font=\tiny]
\tikzstyle{unit}=[draw,rounded corners=2pt,drop shadow,font=\tiny,thick]
%left
\begin{scope}
\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}
\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}
\node[draw,circle,minimum size=1em,inner sep=1pt] at (0,\d) (add_\x) {\scriptsize\bfnew{+}};
\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}
\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}
\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=0.1em]ln_1.90) -- ([yshift=-0.1em]sa_1.-90);
......@@ -44,17 +44,17 @@
\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}
\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!20] 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=blue!20] at (-3em,12em) (relu_1) {RELU};
\node[unit,fill=blue!20] at (3em,12em) (relu_2) {RELU};
\node[unit,fill=cyan!20] at (0em,18em) (conv_3) {Sep卷积$9 \times 1$:256};
\node[unit,fill=red!30] at (0,4em) (glu_1) {门控线性单元:512};
\node[unit,fill=red!30] at (-3em,10em) (conv_1) {卷积$1 \times 1$:2048};
\node[unit,fill=cyan!30] at (3em,10em) (conv_2) {卷积$3 \times 1$:256};
\node[unit,fill=blue!30] at (-3em,12em) (relu_1) {RELU};
\node[unit,fill=blue!30] at (3em,12em) (relu_2) {RELU};
\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);
......@@ -81,15 +81,15 @@
\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=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=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=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=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){非空间层};
\begin{pgfonlayer}{background}
......
......@@ -2,20 +2,20 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle{hnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=green!30]
\tikzstyle{tnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=4.5em,rounded corners=5pt,fill=red!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,draw,thick]
\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=west,hnode] (n2) at ([xshift=1em,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] (n4) at ([xshift=1em,yshift=0em]n3.east) {$\cdots$};
\node [anchor=west,hnode] (n5) at ([xshift=1em,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] (t2) at ([xshift=2.8em,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] (t4) at ([xshift=2.8em,yshift=1em]t3.north) {$\mathbi{h}_{2m-1}$};
\node [anchor=west,hnode] (n2) at ([xshift=2em,yshift=0em]n1.east) {$\mathbi{h}_2$};
\node [anchor=west,hnode] (n3) at ([xshift=2em,yshift=0em]n2.east) {$\mathbi{h}_3$};
\node [anchor=west,hnode] (n4) at ([xshift=2em,yshift=0em]n3.east) {$\cdots$};
\node [anchor=west,hnode] (n5) at ([xshift=2em,yshift=0em]n4.east) {$\mathbi{h}_m$};
\node [anchor=south,tnode] (t1) at ([xshift=3.3em,yshift=1em]n1.north) {$\mathbi{h}_{m+1}$};
\node [anchor=south,tnode] (t2) at ([xshift=3.3em,yshift=1em]t1.north) {$\mathbi{h}_{m+2}$};
\node [anchor=south,tnode] (t3) at ([xshift=3.3em,yshift=1em]t2.north) {$\cdots$};
\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]n2.east) -- ([xshift=0em,yshift=0em]n3.west);
......
\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{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]
\begin{pgfonlayer}{background}
......@@ -10,14 +10,14 @@
\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=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=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=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 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=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!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 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 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!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}
......
......@@ -2,9 +2,9 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle{lnode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=3.5em,rounded corners=2pt,draw]
\tikzstyle{snode}=[rectangle,inner sep=0mm,minimum height=1.5em,minimum width=0.8em,rounded corners=2pt,draw]
\tikzstyle{vlnode}=[rectangle,inner sep=0mm,minimum height=1em,minimum width=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,thick]
\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$};
......@@ -13,53 +13,53 @@
\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] (n5) at ([xshift=1.2em,yshift=0em]n2.east) {};
\node [anchor=west,lnode] (n6) at ([xshift=1.2em,yshift=0em]n3.east) {};
\node [anchor=west,lnode] (n4) at ([xshift=1em,yshift=0em]n1.east) {};
\node [anchor=west,lnode] (n5) at ([xshift=1em,yshift=0em]n2.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=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=yellow!30] (nc12) at ([xshift=0em,yshift=0em]nc11.east) {};
\node [anchor=west,snode,fill=red!30] (nc13) at ([xshift=0em,yshift=0em]nc12.east) {};
\node [anchor=west,snode,fill=blue!30] (nc14) at ([xshift=0em,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,fill=yellow!30] (nc12) at ([xshift=-0.06em,yshift=0em]nc11.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=-0.06em,yshift=0em]nc13.east) {};
\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=yellow!30] (nc22) at ([xshift=0em,yshift=0em]nc21.east) {};
\node [anchor=west,snode,fill=red!30] (nc23) at ([xshift=0em,yshift=0em]nc22.east) {};
\node [anchor=west,snode,fill=blue!30] (nc24) at ([xshift=0em,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,fill=yellow!30] (nc22) at ([xshift=-0.06em,yshift=0em]nc21.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=-0.06em,yshift=0em]nc23.east) {};
\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=yellow!30] (nc32) at ([xshift=0em,yshift=0em]nc31.east) {};
\node [anchor=west,snode,fill=red!30] (nc33) at ([xshift=0em,yshift=0em]nc32.east) {};
\node [anchor=west,snode,fill=blue!30] (nc34) at ([xshift=0em,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,fill=yellow!30] (nc32) at ([xshift=-0.06em,yshift=0em]nc31.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=-0.06em,yshift=0em]nc33.east) {};
\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=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=yellow!30] (ns12) at ([xshift=0em,yshift=0em]ns11.east) {};
\node [anchor=west,snode,fill=red!30] (ns13) at ([xshift=0em,yshift=0em]ns12.east) {};
\node [anchor=west,snode,fill=blue!30] (ns14) at ([xshift=0em,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,fill=yellow!30] (ns12) at ([xshift=-0.06em,yshift=0em]ns11.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=-0.06em,yshift=0em]ns13.east) {};
\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=yellow!30] (ns22) at ([xshift=0em,yshift=0em]ns21.east) {};
\node [anchor=west,snode,fill=red!30] (ns23) at ([xshift=0em,yshift=0em]ns22.east) {};
\node [anchor=west,snode,fill=blue!30] (ns24) at ([xshift=0em,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,fill=yellow!30] (ns22) at ([xshift=-0.06em,yshift=0em]ns21.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=-0.06em,yshift=0em]ns23.east) {};
\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=yellow!30] (ns32) at ([xshift=0em,yshift=0em]ns31.east) {};
\node [anchor=west,snode,fill=red!30] (ns33) at ([xshift=0em,yshift=0em]ns32.east) {};
\node [anchor=west,snode,fill=blue!30] (ns34) at ([xshift=0em,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,fill=yellow!30] (ns32) at ([xshift=-0.06em,yshift=0em]ns31.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=-0.06em,yshift=0em]ns33.east) {};
\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=north west,vlnode,fill=yellow!30] (ln2) at ([xshift=-0.4em,yshift=-0.4em]ln1.north west) {};
......@@ -71,7 +71,7 @@
\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);
......@@ -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]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}] ([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}] ([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);
......
......@@ -3,9 +3,9 @@
\begin{center}
\begin{tikzpicture}
\tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=4em,minimum width=4em,rounded corners=5pt,thick,draw,fill=blue!15]
\tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=6em,rounded corners=5pt,thick,fill=red!15,draw]
\tikzstyle{ebnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,fill=ugreen!15,draw]
\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!30,draw]
\tikzstyle{ebnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,fill=green!30,draw]
\begin{scope}[]
......@@ -15,7 +15,8 @@
\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,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);
......@@ -24,7 +25,9 @@
\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]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.south)--([xshift=-0em,yshift=-0em]add1.north);
......
......@@ -3,9 +3,9 @@
\begin{center}
\begin{tikzpicture}
\tikzstyle{manode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=10em,rounded corners=5pt,thick,draw,fill=teal!20]
\tikzstyle{ffnnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,thick,fill=red!20,draw]
\tikzstyle{lnnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=2.5em,rounded corners=5pt,thick,fill=green!20,draw]
\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!30,draw]
\tikzstyle{lnnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=2.5em,rounded corners=5pt,thick,fill=green!30,draw]
\begin{scope}[]
......@@ -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] (w2) at ([xshift=0.5em,yshift=0em]f1.east){以概率\\$p$丢弃};
\draw[-] ([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.west)--([xshift=-0em,yshift=0em]n2.east);
\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[-] ([xshift=0em,yshift=0em]n5.south)--([xshift=-0em,yshift=-0em]n5.north);
\draw[-,thick] ([xshift=0em,yshift=0em]n5.west)--([xshift=-0em,yshift=0em]n5.east);
\draw[-,thick] ([xshift=0em,yshift=0em]n5.south)--([xshift=-0em,yshift=-0em]n5.north);
\end{scope}
\end{tikzpicture}
......
\begin{tikzpicture}
\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]
\node [anchor=west,cirnode] (n1) at (0, 0) {$\mathbi{h}_{i-2}^l$};
......@@ -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) {};
\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=orange!20] (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=red!30] (r1) at ([xshift=-3.5em,yshift=2.5em]n2.north) {$\textrm{head}_1$};
\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!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}$};
......
......@@ -2,8 +2,8 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle{enode}=[rectangle,inner sep=0mm,minimum height=5em,minimum width=5em,rounded corners=7pt,fill=green!30]
\tikzstyle{dnode}=[rectangle,inner sep=0mm,minimum height=2em,minimum width=6.5em,rounded corners=5pt,fill=red!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,draw,thick]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=2em,minimum width=4em]
\node [anchor=south west] (w1) at (0,0) {汉语(源语言)};
......
......@@ -3,8 +3,8 @@
\begin{center}
\begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=blue!30]
\tikzstyle{arnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=4em,rounded corners=5pt,fill=red!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,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em]
{\small
......
......@@ -6,14 +6,14 @@
\begin{scope}[minimum height = 20pt]
\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,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=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=red!20,inner xsep=5pt,rounded corners=2pt] (ln2) at ([xshift=4em]F2.east){\small{$F$}};
\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,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] (x4) at ([xshift=4em]n2.east) {$\mathbi{x}_{l+1}$};
......
\begin{tikzpicture}
\tikzstyle{Sanode} = [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];
\tikzstyle{ffnnode} = [minimum height=1.1em,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];
\tikzstyle{inputnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!20];
\tikzstyle{posnode} = [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!10!white];
\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,thick];
\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,thick];
\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,thick];
\tikzstyle{standard} = [rounded corners=3pt];
\begin{scope}
......
......@@ -4,9 +4,9 @@
\begin{tikzpicture}
\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[anchor=west,node,fill=yellow!20] (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[node,fill=red!30] (n1) at (0,0){\scriptsize\bfnew{超网络}\\ [1ex] 模型结构参数 \\[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!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] (n2.0) -- node[above,align=center,font=\scriptsize]{根据结构参数\\离散化结构}(n3.180);
......
......@@ -2,15 +2,15 @@
%%% outline
%-------------------------------------------------------------------------
\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[anchor=south,node,fill=green!20] (n2) at ([yshift=5em]n1.north){\small\bfnew{智能体}};
\node[node,fill=red!30] (n1) at (0,0){\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=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=-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);
\end{tikzpicture}
......
......@@ -6,24 +6,24 @@
\begin{scope}[minimum height = 20pt]
\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=green!20,inner xsep=5pt,rounded corners=2pt] (f1) at ([xshift=0.6em]ln1.east){\small{$F$}};
\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!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] (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=green!20,inner xsep=5pt,rounded corners=2pt] (f12) at ([xshift=0.6em]ln12.east){\small{$F$}};
\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!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] (x22) at ([xshift=1em]n12.east) {$\mathbi{x}_{l+2}$};
\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=green!20,inner xsep=5pt,rounded corners=2pt] (f2) at ([xshift=0.6em]ln2.east){\small{$F$}};
\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!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=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] (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=green!20,inner xsep=5pt,rounded corners=2pt] (f22) at ([xshift=0.6em]ln22.east){\small{$F$}};
\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!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=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){};
......
......@@ -3,8 +3,8 @@
\begin{center}
\begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=blue!30]
\tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.6em,minimum width=3em,rounded corners=5pt,fill=orange!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,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.6em]
{\small
......
......@@ -3,8 +3,8 @@
\begin{center}
\begin{tikzpicture}
\tikzstyle{wrnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=blue!30]
\tikzstyle{srnode}=[rectangle,inner sep=0mm,minimum height=1.8em,minimum width=3em,rounded corners=5pt,fill=orange!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,draw,thick]
\tikzstyle{dotnode}=[inner sep=0mm,minimum height=0.5em,minimum width=1.5em]
\tikzstyle{wnode}=[inner sep=0mm,minimum height=1.8em]
......@@ -48,9 +48,9 @@
\node [anchor=south,wnode] (w10) at ([xshift=0em,yshift=0.5em]c3.north) {$\mathbi{e}_{w_2}$};
\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!20,rounded corners=8pt] [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 = (c1) (w8)] (box6) {};
\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!30,rounded corners=8pt,draw,thick] [fit = (c3) (w10)] (box8) {};
\end{pgfonlayer}
\node [anchor=south,wrnode] (wr1) at ([xshift=0em,yshift=1em]box6.north) {$\mathbi{h}_{w_1}$};
......
......@@ -3,7 +3,7 @@
\begin{center}
\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{wnode}=[inner sep=0mm,minimum height=1.6em]
{\small
......
......@@ -52,7 +52,7 @@
\begin{figure}[htp]
\centering
\input{./Chapter15/Figures/figure-relative-position-coding-and-absolute-position-coding}
\caption{绝对位置编码(左)和相对位置编码(右)}
\caption{绝对位置编码和相对位置编码}
\label{fig:15-1}
\end{figure}
%-------------------------------------------
......@@ -118,7 +118,6 @@
\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}的基础上,注意力权重的计算方式调整为:
\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 \\
......@@ -624,7 +623,6 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x}
\end{eqnarray}
\parinterval 其中$\textrm{Var}(\cdot)$表示求方差操作,由于在大多数情况下,现有模型中的各种标准化方法可以维持$E[w_j]^2$$E[x_j]^2$等于或者近似为0。因此,模型中一层神经元输出的方差可以表示为:
\begin{eqnarray}
\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})
......@@ -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}
\label{eq:15-45}
\end{eqnarray}
\vspace{0.5em}
%\vspace{0.5em}
\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 初始化方法最终的约束条件则为:
......@@ -800,14 +798,14 @@ C(\mathbi{x}_j \mathbi{W}_K,\omega) &=& (\mathbi{x}_{j-\omega},\ldots,\mathbi{x}
\item 在训练的初期,模型会先经历一个学习率预热的过程:
\begin{eqnarray}
lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num \cdot warmup\_steps^{-0.5}
\label{eq:15-46}
\label{eq:15-49}
\end{eqnarray}
\noindent 这里,$step\_num$表示参数更新的次数,$warmup\_step$表示预热的更新次数,$d_{\textrm{model}}$表示Transformer模型的隐层大小,$lr$是学习率。
\vspace{0.5em}
\item 在之后的训练过程中,每当增加模型深度时,学习率都会重置到峰值,之后进行相应的衰减:
\begin{eqnarray}
lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\label{eq:15-47}
\label{eq:15-50}
\end{eqnarray}
\noindent 这里$step\_num$代表学习率重置后更新的步数。
\vspace{0.5em}
......@@ -838,13 +836,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\parinterval {\chapterthirteen}提到的Layer Dropout方法可以有效地缓解这个问题。以编码器为例, Layer Dropout的过程可以被描述为:在训练过程中,对自注意力子层或前馈神经网络子层进行随机丢弃,以减少不同子层之间的相互适应。这里选择Pre-Norm结构作为基础架构,它可以被描述为:
\begin{eqnarray}
\mathbi{x}_{l+1} &=& F(\textrm{LN}(\mathbi{x}_l)) + \mathbi{x}_l
\label{eq:15-48}
\label{eq:15-51}
\end{eqnarray}
\noindent 其中,$\textrm{LN}( \cdot )$表示层标准化函数, $F( \cdot )$表示自注意力机制或者前馈神经网络,$\mathbi{x}_l$表示第$l$个子层的输入。之后,使用一个掩码$\textrm{Mask}$(值为0或1)来控制每个子层是正常计算还是丢弃。于是,该子层的计算公式可以被重写为:
\begin{eqnarray}
\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}
\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}
\parinterval 使用句法信息的一种简单的方法是将源语言句子编码成一个二叉树结构\footnote[6]{所有句法树都可以通过二叉化方法转化为二叉树(见{\chaptereight})。},树节点的信息是由左子树和右子树变换而来,如下所示:
\begin{eqnarray}
\mathbi{h}_p &=& f_\textrm{tree}(\mathbi{h}_l,\mathbi{h}_r)
\label{eq:15-50}
\label{eq:15-53}
\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}
\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}
%----------------------------------------------
......@@ -965,7 +962,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\parinterval 不同于直接对树结构进行编码,另一种方法是将单词、句法信息等直接转换为特征向量拼接到一起,作为机器翻译系统的输入\upcite{DBLP:conf/wmt/SennrichH16}。这种方法的优点在于,句法信息可以无缝融入到现有神经机器翻译框架,对系统结构的修改很小。以基于循环神经网络的翻译模型为例,可以用如下方式计算输入序列第$i$个位置的表示结果:
\begin{eqnarray}
\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}
\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}
\end{figure}
%-------------------------------------------
\parinterval 在对句法树结构进行序列化的基础上,可以用句法树节点与原始的词信息构造出新的融合表示${\mathbi{h}'}_i$,并使用这种新的表示计算上下文向量,如下:
\parinterval 在对句法树的树结构进行序列化的基础上,可以用句法树节点与原始的词信息一同构造出新的融合表示${\mathbi{h}'}_i$,并使用这种新的表示计算上下文向量,如下:
\begin{eqnarray}
\mathbi{C}_j &=& \sum_{i=1}^m \alpha_{i,j} {\mathbi{h}'}_i
\label{eq:15-53}
\label{eq:15-56}
\end{eqnarray}
\noindent 其中,$m$是源语言句子的长度。新的融合表示${\mathbi{h}'}_i$有如下几种计算方式\upcite{DBLP:conf/acl/LiXTZZZ17}
\begin{itemize}
\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$
\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}
\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}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
......@@ -1010,6 +1002,12 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\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}
%----------------------------------------------------------------------------------------
......@@ -1018,7 +1016,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsection{解码器使用句法信息}\label{subsec-15.3.2}
\parinterval 在解码器中使用句法信息,一种最直接的方式是将目标语言句法树结构进行线性化,然后目标语言句子就变成了一个含有句法标记和单词的混合序列。这样,神经机器翻译系统不需要进行修改,直接使用句法树序列化的结果进行训练和推断\upcite{Aharoni2017TowardsSN}。图\ref{fig:15-24}展示了一个目标语言句法树经过线性化后的结果。
\parinterval 在解码器中使用句法信息,一种最直接的方式是将目标语言句法树结构进行线性化,然后目标语言句子就变成了一个含有句法标记和单词的混合序列。这样,神经机器翻译系统不需要进行修改,可以直接使用句法树序列化的结果进行训练和推断\upcite{Aharoni2017TowardsSN}。图\ref{fig:15-24}展示了一个目标语言句法树经过线性化后的结果。
%----------------------------------------------
\begin{figure}[htp]
......@@ -1050,7 +1048,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{figure}[htp]
\centering
\input{./Chapter15/Figures/figure-parallel-RNN-structure}
\caption{词预测模型和动作模型{\color{red} 看前面的文字:一个叫动作模型,一个叫词预测模型。还有右侧图的依存的箭头方向一定再确定一下!}}
\caption{词预测模型和动作模型}
\label{fig:15-26}
\end{figure}
%-------------------------------------------
......@@ -1083,7 +1081,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\end{figure}
%-------------------------------------------
\parinterval 那么网络结构搜索究竟是一种什么样的技术呢?如图\ref{fig:15-28}所示,在传统机器学习方法中,研究人员需要设计大量的特征来描述待解决的问题,即“特征工程”。在深度学习时代,神经网络模型可以完成特征的抽取和学习,但是却需要人工设计神经网络结构,这项工作仍然十分繁重。因此一些科研人员开始思考,能否将设计模型结构的工作也交由机器自动完成?深度学习方法中模型参数能够通过梯度下降等方式进行自动优化,那么模型结构是否可以也看做是一种特殊的参数,使用搜索算法自动找到最适用于当前任务的模型结构?网络结构搜索应运而生。
\parinterval 那么网络结构搜索究竟是一种什么样的技术呢?如图\ref{fig:15-28}所示,在传统机器学习方法中,研究人员需要设计大量的特征来描述待解决的问题,即“特征工程”。在深度学习时代,神经网络模型可以完成特征的抽取和学习,但是却需要人工设计神经网络结构,这项工作仍然十分繁重。因此一些科研人员开始思考,能否将设计模型结构的工作也交由机器自动完成?深度学习方法中模型参数能够通过梯度下降等方式进行自动优化,那么模型结构是否可以也看做是一种特殊的参数,使用搜索算法自动找到最适用于当前任务的模型结构?基于上述想法,网络结构搜索应运而生。
%----------------------------------------------
\begin{figure}[htp]
......@@ -1094,7 +1092,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\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
......@@ -1106,7 +1104,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{eqnarray}
\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}
\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}
\begin{itemize}
\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}
\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}
\end{itemize}
......@@ -1153,14 +1151,13 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsubsection{2. 搜索策略}
\parinterval 在定义好搜索空间之后,如何进行网络结构的搜索也同样重要。该过程被称为搜索策略的设计,其主要目的是根据已找到的模型结构计算出下一个最有潜力的模型结构,为保证模型有效性,在一些方法中也会引入外部知识(如经验性的模型结构或张量运算规则)对搜索过程进行剪枝。目前常见的搜索策略一般包括基于进化算法的方法、基于强化学习的方法、基于梯度的方法等方式
\parinterval 在定义好搜索空间之后,如何进行网络结构的搜索也同样重要。该过程被称为搜索策略的设计,其主要目的是根据已找到的模型结构计算出下一个最有潜力的模型结构,为保证模型有效性,在一些方法中也会引入外部知识(如经验性的模型结构或张量运算规则)对搜索过程进行剪枝。目前常见的搜索策略一般包括基于进化算法的方法、基于强化学习的方法以及基于梯度的方法等等
\begin{itemize}
\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}
\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]
......@@ -1172,7 +1169,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
%-------------------------------------------
\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}
%----------------------------------------------
......@@ -1192,15 +1189,15 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\subsubsection{3. 性能评估}\label{subsubsec-15.4.2.3}
\parinterval 由于结构搜索过程中会产生大量的中间结构,因此需要快速评估这些结构的性能优劣,以保证搜索中可以有效的挑选高质量的模型结构。有以下三方面问题需要考虑:
\parinterval 由于结构搜索过程中会产生大量的中间结构,因此需要快速评估这些结构的性能优劣,以保证在搜索中可以有效地挑选高质量的模型结构。对于该问题,可以从以下三个方面来考虑:
\begin{itemize}
\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}
\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}
\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}
\end{itemize}
......@@ -1210,7 +1207,7 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\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
......@@ -1222,23 +1219,20 @@ lr &=& d_{\textrm{model}}^{-0.5}\cdot step\_num^{-0.5}
\begin{itemize}
\vspace{0.5em}
\item 搜索模型中的局部结构:在机器翻译任务中,一种典型的局部模型结构搜索方法是面向激活函数的搜索\upcite{DBLP:conf/iclr/RamachandranZL18},该方法将激活函数看作是一元、二元函数的若干次复合。例如,Swish 激活函数就是一种被找到的新的激活函数,如下:
\item {\small\bfnew{搜索模型中的局部结构}}在机器翻译任务中,一种典型的局部模型结构搜索方法是面向激活函数的搜索\upcite{DBLP:conf/iclr/RamachandranZL18},该方法将激活函数看作是一元、二元函数的若干次复合。例如,Swish 激活函数就是一种被找到的新的激活函数,如下:
\begin{eqnarray}
f(x) &=& x \cdot \delta(\beta x) \\
\delta(z) &=& {(1 + \exp{(-z)})}^{-1}
\label{eq:15-60}
\end{eqnarray}
\noindent 相比传统人工设计的激活函数ReLU而言,Swish函数在多个机器翻译任务取得了不错的效果。
\noindent 相比于人工设计的激活函数ReLU而言,Swish函数在多个机器翻译任务取得了不错的效果。
\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}
\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
......@@ -1246,14 +1240,13 @@ f(x) &=& x \cdot \delta(\beta x) \\
\subsubsection{2. 模型效率优化}
\parinterval 除了能够提高机器翻译模型性能之外,网络结构搜索也能够优化模型的执行效率。从实用的角度出发,可以在进行结构搜索的同时考虑设备的计算能力,希望找到更适合运行设备的模型结构。同时也可以对大模型进行压缩,加速其在推断过程中的效率,这方面的工作不仅限于在机器翻译模型上,也有部分工作对基于注意力机制的预训练模型进行压缩。
\parinterval 网络结构搜索除了能够提高机器翻译模型性能之外,也能够优化模型的执行效率。从实用的角度出发,可以在进行结构搜索的同时考虑设备的计算能力,希望找到更适合运行设备的模型结构。同时,网络结构搜索也可以用来对大模型进行压缩,加速其在推断过程中的效率,这方面的工作不仅限于在机器翻译模型上,也有部分工作对基于注意力机制的预训练模型进行压缩。
\begin{itemize}
\vspace{0.5em}
\item 面向特定设备的模型结构优化:可以在结构优化的过程中将设备的算力作为一个约束\upcite{DBLP:conf/acl/WangWLCZGH20}。具体来说,可以将搜索空间中各种结构建模在同一个超网络中,通过权重共享的方式进行训练。使用设备算力约束子模型,并通过进化算法对子模型进行搜索,搜索到适用于目标设备的模型结构。该方法搜索到的模型能够在保证模型性能不变前提下获得较大的效率提升。
\item {\small\bfnew{面向特定设备的模型结构优化}}。可以在结构优化的过程中将设备的算力作为一个约束\upcite{DBLP:conf/acl/WangWLCZGH20}。具体来说,可以将搜索空间中各种结构建模在同一个超网络中,通过权重共享的方式进行训练。使用设备算力约束子模型,并通过进化算法对子模型进行搜索,搜索到适用于目标设备的模型结构。该方法搜索到的模型能够在保证模型性能不变前提下获得较大的效率提升。
\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}
\end{itemize}
......@@ -1268,18 +1261,18 @@ f(x) &=& x \cdot \delta(\beta x) \\
\sectionnewpage
\section{小结及拓展阅读}
\parinterval 模型结构优化一直是机器翻译研究的重要方向。一方面,对于通用框架(如注意力机制)的结构改良可以服务于多种自然语言处理任务,另一方面,针对机器翻译的问题设计相适应的模型结构也是极具价值的。本章节重点介绍了神经机器翻译中结构优化的几种方法,内容涉及注意力机制的改进、深层神经网络的构建、句法结构的使用以及自动结构搜索等几个方面。此外,还有若干问题值得关注:
\parinterval 模型结构优化一直是机器翻译研究的重要方向。一方面,对于通用框架(如注意力机制)的结构改良可以服务于多种自然语言处理任务,另一方面,针对机器翻译中存在的问题设计相适应的模型结构也是极具价值的。本章节重点介绍了神经机器翻译中几种结构优化方法,内容涉及注意力机制的改进、深层神经网络的构建、句法结构的使用以及自动结构搜索等几个方面。此外,还有若干问题值得关注:
\begin{itemize}
\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}
\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}
\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}
\end{itemize}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论