Commit ad08c44b by zengxin

合并分支 'zengxin' 到 'caorunzhe'

Zengxin

查看合并请求 !378
parents 80c9c483 c63f0aad
......@@ -15,9 +15,9 @@
\node[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west] (eemb\x) at ([xshift=0.4\base]eemb\y.east) {\tiny{$e_x()$}};
\foreach \x in {1,2,...,3}
\node[rnnnode,fill=blue!30!white,anchor=south] (enc\x) at ([yshift=0.3\base]eemb\x.north) {};
\node[] (enclabel1) at (enc1) {\tiny{$\vectorn{\emph{h}}_{m-2}$}};
\node[] (enclabel2) at (enc2) {\tiny{$\vectorn{\emph{h}}_{m-1}$}};
\node[rnnnode,fill=purple!30!white] (enclabel3) at (enc3) {\tiny{$\vectorn{\emph{h}}_{m}$}};
\node[] (enclabel1) at (enc1) {\tiny{$\mathbi{h}_{m-2}$}};
\node[] (enclabel2) at (enc2) {\tiny{$\mathbi{h}_{m-1}$}};
\node[rnnnode,fill=purple!30!white] (enclabel3) at (enc3) {\tiny{$\mathbi{h}_{m}$}};
\node[wordnode,left=0.4\base of enc1] (init1) {$\cdots$};
\node[wordnode,left=0.4\base of eemb1] (init2) {$\cdots$};
......@@ -29,7 +29,7 @@
\foreach \x in {1,2,...,3}
\node[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=south] (demb\x) at ([yshift=\base]enc\x.north) {\tiny{$e_y()$}};
\foreach \x in {1,2,...,3}
\node[rnnnode,fill=blue!30!white,anchor=south] (dec\x) at ([yshift=0.3\base]demb\x.north) {{\tiny{$\vectorn{\emph{s}}_\x$}}};
\node[rnnnode,fill=blue!30!white,anchor=south] (dec\x) at ([yshift=0.3\base]demb\x.north) {{\tiny{$\mathbi{s}_\x$}}};
\foreach \x in {1,2,...,3}
\node[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=south] (softmax\x) at ([yshift=0.3\base]dec\x.north) {\tiny{Softmax}};
\node[wordnode,right=0.4\base of demb3] (end1) {$\cdots$};
......@@ -73,7 +73,7 @@
\draw[-latex'] (enc3.north) .. controls +(north:0.3\base) and +(east:\base) .. (bridge) .. controls +(west:2.7\base) and +(west:0.3\base) .. (dec1.west);
{
\node [anchor=east] (line1) at ([xshift=-3em,yshift=0.5em]softmax1.west) {\scriptsize{基于RNN的隐层状态$\vectorn{\emph{s}}_i$}};
\node [anchor=east] (line1) at ([xshift=-3em,yshift=0.5em]softmax1.west) {\scriptsize{基于RNN的隐层状态$\mathbi{s}_i$}};
\node [anchor=north west] (line2) at ([yshift=0.3em]line1.south west) {\scriptsize{预测目标词的概率}};
\node [anchor=north west] (line3) at ([yshift=0.3em]line2.south west) {\scriptsize{通常,用Softmax函数}};
\node [anchor=north west] (line4) at ([yshift=0.3em]line3.south west) {\scriptsize{实现 $\funp{P}(y_i|...)$}};
......@@ -90,7 +90,7 @@
\node [anchor=west] (line21) at ([xshift=1.3em,yshift=1.5em]enc3.east) {\scriptsize{源语编码器最后一个}};
\node [anchor=north west] (line22) at ([yshift=0.3em]line21.south west) {\scriptsize{循环单元的输出被}};
\node [anchor=north west] (line23) at ([yshift=0.3em]line22.south west) {\scriptsize{看作是句子的表示,}};
\node [anchor=north west] (line24) at ([yshift=0.3em]line23.south west) {\scriptsize{记为$\vectorn{\emph{C}}$}};
\node [anchor=north west] (line24) at ([yshift=0.3em]line23.south west) {\scriptsize{记为$\mathbi{C}$}};
}
\begin{pgfonlayer}{background}
......
......@@ -8,17 +8,17 @@
\begin{scope}
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h1) at (0,0) {\scriptsize{$\vectorn{h}_1$}};
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h2) at ([xshift=1em]h1.east) {\scriptsize{$\vectorn{h}_2$}};
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h1) at (0,0) {\scriptsize{$\mathbi{h}_1$}};
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h2) at ([xshift=1em]h1.east) {\scriptsize{$\mathbi{h}_2$}};
\node [anchor=west,inner sep=0pt,minimum width=3em] (h3) at ([xshift=0.5em]h2.east) {\scriptsize{...}};
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h4) at ([xshift=0.5em]h3.east) {\scriptsize{$\vectorn{h}_m$}};
\node [anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h4) at ([xshift=0.5em]h3.east) {\scriptsize{$\mathbi{h}_m$}};
\node [anchor=south,circle,minimum size=1.0em,draw,ublue,thick] (sum) at ([yshift=2em]h2.north east) {};
\draw [thick,-,ublue] (sum.north) -- (sum.south);
\draw [thick,-,ublue] (sum.west) -- (sum.east);
\node [anchor=south,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th1) at ([yshift=2em,xshift=-1em]sum.north west) {\scriptsize{$\vectorn{s}_{j-1}$}};
\node [anchor=west,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th2) at ([xshift=2em]th1.east) {\scriptsize{$\vectorn{s}_{j}$}};
\node [anchor=south,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th1) at ([yshift=2em,xshift=-1em]sum.north west) {\scriptsize{$\mathbi{s}_{j-1}$}};
\node [anchor=west,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th2) at ([xshift=2em]th1.east) {\scriptsize{$\mathbi{s}_{j}$}};
\draw [->] (h1.north) .. controls +(north:0.8) and +(west:1) .. (sum.190) node [pos=0.2,left] {\scriptsize{$\alpha_{1,j}$}};
\draw [->] (h2.north) .. controls +(north:0.6) and +(220:0.2) .. (sum.220) node [pos=0.2,right] {\scriptsize{$\alpha_{2,j}$}};
......@@ -27,7 +27,7 @@
\draw [->] ([xshift=-1.5em]th1.west) -- ([xshift=-0.1em]th1.west);
\draw [->] ([xshift=0.1em]th1.east) -- ([xshift=-0.1em]th2.west);
\draw [->] ([xshift=0.1em]th2.east) -- ([xshift=1.5em]th2.east);
\draw [->] (sum.north) .. controls +(north:0.8) and +(west:0.2) .. ([yshift=-0.4em,xshift=-0.1em]th2.west) node [pos=0.2,right] (ci) {\scriptsize{$\vectorn{C}_{j}$}};
\draw [->] (sum.north) .. controls +(north:0.8) and +(west:0.2) .. ([yshift=-0.4em,xshift=-0.1em]th2.west) node [pos=0.2,right] (ci) {\scriptsize{$\mathbi{C}_{j}$}};
\node [anchor=south,inner sep=1pt] (output) at ([yshift=0.8em]th2.north) {\scriptsize{输出层}};
\draw [->] ([yshift=0.1em]th2.north) -- ([yshift=-0.1em]output.south);
......@@ -39,11 +39,11 @@
\node [anchor=north] (enc42) at ([yshift=0.5em]enc4.south) {\scriptsize{(位置$4$)}};
{
\node [anchor=west] (math1) at ([xshift=5em,yshift=1em]th2.east) {$\vectorn{C}_j = \sum_{i} \alpha_{i,j} \vectorn{h}_i $ \ \ \ \ };
\node [anchor=west] (math1) at ([xshift=5em,yshift=1em]th2.east) {$\mathbi{C}_j = \sum_{i} \alpha_{i,j} \mathbi{h}_i $ \ \ \ \ };
}
{
\node [anchor=north west] (math2) at ([yshift=-2em,xshift=-0.2em]math1.south west) {$\alpha_{i,j} = \frac{\exp(\beta_{i,j})}{\sum_{i'} \exp(\beta_{i',j})}$};
\node [anchor=north west] (math3) at ([yshift=-0em]math2.south west) {$\beta_{i,j} = a(\vectorn{s}_{j-1}, \vectorn{h}_i)$};
\node [anchor=north west] (math3) at ([yshift=-0em]math2.south west) {$\beta_{i,j} = a(\mathbi{s}_{j-1}, \mathbi{h}_i)$};
}
\begin{pgfonlayer}{background}
......
......@@ -2,9 +2,9 @@
\begin{scope}
\tikzstyle{rnnnode} = [minimum height=1.1em,minimum width=2.1em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\node [rnnnode,anchor=west] (h1) at (0,0) {\tiny{$\vectorn{\emph{h}}_1$}};
\node [rnnnode,anchor=west] (h1) at (0,0) {\tiny{$\mathbi{\emph{h}}_1$}};
\node [anchor=west] (h2) at ([xshift=1em]h1.east) {\tiny{...}};
\node [rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east) {\tiny{$\vectorn{\emph{h}}_m$}};
\node [rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east) {\tiny{$\mathbi{\emph{h}}_m$}};
\node [rnnnode,anchor=north,fill=green!20] (e1) at ([yshift=-1em]h1.south) {\tiny{$e_x()$}};
\node [anchor=west] (e2) at ([xshift=1em]e1.east) {\tiny{...}};
\node [rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east) {\tiny{$e_x()$}};
......@@ -19,7 +19,7 @@
\draw [->] ([xshift=0.1em]h1.east) -- ([xshift=-0.1em]h2.west);
\draw [->] ([xshift=0.1em]h2.east) -- ([xshift=-0.1em]h3.west);
\draw [->] ([xshift=-0.8em]h1.west) -- ([xshift=-0.1em]h1.west) node [pos=0,left,inner sep=2pt] {\tiny{0}};
\node [anchor=south] (encoder) at ([xshift=-0.2em]h1.north west) {\scriptsize{\vectorn{编码器}}};
\node [anchor=south] (encoder) at ([xshift=-0.2em]h1.north west) {\scriptsize{\mathbi{编码器}}};
{
\node [rnnnode,anchor=west,fill=green!20] (t1) at ([xshift=3em]h3.east) {\tiny{$e_y()$}};
......@@ -33,14 +33,14 @@
\node [anchor=west,inner sep=2pt] (t5) at ([xshift=0.3em]t4.east) {\tiny{...}};
}
{
\node [rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north) {\tiny{$\vectorn{\emph{s}}_1$}};
\node [rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north) {\tiny{$\mathbi{\emph{s}}_1$}};
}
{
\node [rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north) {\tiny{$\vectorn{\emph{s}}_2$}};
\node [rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north) {\tiny{$\mathbi{\emph{s}}_2$}};
}
{
\node [rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north) {\tiny{$\vectorn{\emph{s}}_3$}};
\node [rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north) {\tiny{$\vectorn{\emph{s}}_4$}};
\node [rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north) {\tiny{$\mathbi{\emph{s}}_3$}};
\node [rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north) {\tiny{$\mathbi{\emph{s}}_4$}};
\node [anchor=west,inner sep=2pt] (s5) at ([xshift=0.3em]s4.east) {\tiny{...}};
}
{
......@@ -131,7 +131,7 @@
}
{
\node [circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c2) at ([yshift=2em]h2.north) {\tiny{$\vectorn{\emph{C}}_2$}};
\node [circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c2) at ([yshift=2em]h2.north) {\tiny{$\mathbi{\emph{C}}_2$}};
\node [anchor=south] (c2label) at (c2.north) {\tiny{\textbf{注意力机制:上下文}}};
\node [anchor=south] (c2more) at ([yshift=-1.5em]c2.south) {\tiny{...}};
\draw [->] (h1.north) .. controls +(north:0.6) and +(250:0.9) .. (c2.250);
......@@ -143,12 +143,12 @@
}
{
\node [circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south) {\tiny{$\vectorn{\emph{C}}_3$}};
\node [circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south) {\tiny{$\mathbi{\emph{C}}_3$}};
\draw [->] ([xshift=-0.7em]c3.west) -- ([xshift=-0.1em]c3.west);
\draw [->] ([xshift=0.1em]c3.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]s3.west);
}
{
\node [circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south) {\tiny{$\vectorn{\emph{C}}_4$}};
\node [circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south) {\tiny{$\mathbi{\emph{C}}_4$}};
\draw [->] ([xshift=-0.7em]c4.west) -- ([xshift=-0.1em]c4.west);
\draw [->] ([xshift=0.1em]c4.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]s4.west);
}
......
......@@ -104,9 +104,9 @@
%\visible<3->
{
% coverage score formula node
\node [anchor=north west] (formula) at ([xshift=-0.3\hnode,yshift=-1.5\hnode]attn11.south) {\small{不同$\vectorn{C}_j$所对应的源语言词的权重是不同的}};
\node [anchor=north west] (example) at (formula.south west) {\footnotesize{$\vectorn{C}_2=0.4 \times \vectorn{h}(\textrm{“你”}) + 0.4 \times \vectorn{h}(\textrm{“什么”}) +$}};
\node [anchor=north west] (example2) at ([yshift=0.4em]example.south west) {\footnotesize{$\ \ \ \ \ \ \ \ 0 \times \vectorn{h}(\textrm{“都”}) + 0.1 \times \vectorn{h}(\textrm{“ 没”}) + ..$}};
\node [anchor=north west] (formula) at ([xshift=-0.3\hnode,yshift=-1.5\hnode]attn11.south) {\small{不同$\mathbi{C}_j$所对应的源语言词的权重是不同的}};
\node [anchor=north west] (example) at (formula.south west) {\footnotesize{$\mathbi{C}_2=0.4 \times \mathbi{h}(\textrm{“你”}) + 0.4 \times \mathbi{h}(\textrm{“什么”}) +$}};
\node [anchor=north west] (example2) at ([yshift=0.4em]example.south west) {\footnotesize{$\ \ \ \ \ \ \ \ 0 \times \mathbi{h}(\textrm{“都”}) + 0.1 \times \mathbi{h}(\textrm{“ 没”}) + ..$}};
}
%\visible<3->
......@@ -138,12 +138,12 @@
%\visible<2->
{
\node[anchor=west] (sc1) at ([xshift=0.9\hnode]attn16.east) {$\vectorn{C}_1 = \sum_{i=1}^{8} \alpha_{i1} \vectorn{h}_{i}$};
\node[anchor=west] (sc1) at ([xshift=0.9\hnode]attn16.east) {$\mathbi{C}_1 = \sum_{i=1}^{8} \alpha_{i1} \mathbi{h}_{i}$};
}
%\visible<3->
{
\node[anchor=west] (sc2) at ([xshift=0.9\hnode,yshift=0.0\hnode]attn26.east) {$\vectorn{C}_2 = \sum_{i=1}^{8} \alpha_{i2} \vectorn{h}_{i}$};
\node[anchor=west] (sc2) at ([xshift=0.9\hnode,yshift=0.0\hnode]attn26.east) {$\mathbi{C}_2 = \sum_{i=1}^{8} \alpha_{i2} \mathbi{h}_{i}$};
}
\end{tikzpicture}
\ No newline at end of file
......@@ -78,8 +78,8 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at (aux71) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at (aux71) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\end{scope}
......
......@@ -91,8 +91,8 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at (aux71) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at (aux71) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\end{scope}
......
......@@ -109,11 +109,11 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at (aux71) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at (aux71) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
{
\node[wordnode,anchor=east] () at (aux87) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=south] () at (aux78) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=east] () at (aux87) {$\mathbi{h}_{t}$};
\node[wordnode,anchor=south] () at (aux78) {$\mathbi{h}_{t}$};
}
\end{scope}
......
......@@ -84,9 +84,9 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\vectorn{\emph{c}}_{t-1}$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbi{c}_{t-1}$};
\end{scope}
......
......@@ -99,9 +99,9 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\vectorn{\emph{c}}_{t-1}$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbi{c}_{t-1}$};
\end{scope}
......
......@@ -113,11 +113,11 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\vectorn{\emph{c}}_{t-1}$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbi{c}_{t-1}$};
{
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\vectorn{\emph{c}}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\mathbi{c}_{t}$};
}
\end{scope}
......
......@@ -131,15 +131,15 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\vectorn{\emph{c}}_{t-1}$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbi{c}_{t-1}$};
{
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\vectorn{\emph{c}}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\mathbi{c}_{t}$};
}
{
\node[wordnode,anchor=east] () at (aux68) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux29) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=east] () at (aux68) {$\mathbi{h}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux29) {$\mathbi{h}_{t}$};
}
\end{scope}
......
......@@ -4,17 +4,17 @@
\tikzstyle{rnode} = [draw,minimum width=3.5em,minimum height=1.2em]
\node [rnode,anchor=south west,fill=red!20!white] (value1) at (0,0) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=1em]value1.south east) {\scriptsize{$\vectorn{h}(\textrm{什么})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=1em]value2.south east) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=1em]value3.south east) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value1) at (0,0) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=1em]value1.south east) {\scriptsize{$\mathbi{h}(\textrm{什么})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=1em]value2.south east) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=1em]value3.south east) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key1) at ([yshift=0.2em]value1.north west) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key2) at ([yshift=0.2em]value2.north west) {\scriptsize{$\vectorn{h}(\textrm{什么})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key3) at ([yshift=0.2em]value3.north west) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key4) at ([yshift=0.2em]value4.north west) {\scriptsize{$\vectorn{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key1) at ([yshift=0.2em]value1.north west) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key2) at ([yshift=0.2em]value2.north west) {\scriptsize{$\mathbi{h}(\textrm{什么})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key3) at ([yshift=0.2em]value3.north west) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=south west,fill=green!20!white] (key4) at ([yshift=0.2em]value4.north west) {\scriptsize{$\mathbi{h}(\textrm{})$}};
\node [rnode,anchor=east] (query) at ([xshift=-2em]key1.west) {\scriptsize{$\vectorn{s}(\textrm{you})$}};
\node [rnode,anchor=east] (query) at ([xshift=-2em]key1.west) {\scriptsize{$\mathbi{s}(\textrm{you})$}};
\node [anchor=east] (querylabel) at ([xshift=-0.2em]query.west) {\scriptsize{query}};
\draw [->] ([yshift=1pt,xshift=6pt]query.north) .. controls +(90:1em) and +(90:1em) .. ([yshift=1pt]key1.north);
......
......@@ -141,15 +141,15 @@
\end{scope}
\begin{scope}
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\vectorn{\emph{h}}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\vectorn{\emph{x}}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\vectorn{\emph{c}}_{t-1}$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbi{h}_{t-1}$};
\node[wordnode,anchor=west] () at (aux12) {$\mathbi{x}_t$};
\node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbi{c}_{t-1}$};
{
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\vectorn{\emph{c}}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux59) {$\mathbi{c}_{t}$};
}
{
\node[wordnode,anchor=east] () at (aux68) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux29) {$\vectorn{\emph{h}}_{t}$};
\node[wordnode,anchor=east] () at (aux68) {$\mathbi{h}_{t}$};
\node[wordnode,anchor=south] () at ([xshift=-0.5\base]aux29) {$\mathbi{h}_{t}$};
}
\end{scope}
......@@ -170,19 +170,19 @@
\begin{scope}
{
% forget gate formula
\node[formulanode,anchor=south east,text width=10em] () at ([shift={(4\base,1.5\base)}]aux51) {遗忘门\\$\vectorn{\emph{f}}_t=\sigma(\vectorn{\emph{W}}_f[\vectorn{\emph{h}}_{t-1},\vectorn{\emph{x}}_t]+\vectorn{\emph{b}}_f)$};
\node[formulanode,anchor=south east,text width=10em] () at ([shift={(4\base,1.5\base)}]aux51) {遗忘门\\$\mathbi{f}_t=\sigma(\mathbi{W}_f[\mathbi{h}_{t-1},\mathbi{x}_t]+\mathbi{b}_f)$};
}
{
% input gate formula
\node[formulanode,anchor=north east,text width=10em] () at ([shift={(4\base,-1.5\base)}]aux21) {输入门\\$\vectorn{\emph{i}}_t=\sigma(\vectorn{\emph{W}}_i[\vectorn{\emph{h}}_{t-1},\vectorn{\emph{x}}_t]+\vectorn{\emph{b}}_i)$\\$\hat{\vectorn{\emph{c}}}_t=\mathrm{tanh}(\vectorn{\emph{W}}_c[\vectorn{\emph{h}}_{t-1},\vectorn{\emph{x}}_t]+\vectorn{\emph{b}}_c)$};
\node[formulanode,anchor=north east,text width=10em] () at ([shift={(4\base,-1.5\base)}]aux21) {输入门\\$\mathbi{i}_t=\sigma(\mathbi{W}_i[\mathbi{h}_{t-1},\mathbi{x}_t]+\mathbi{b}_i)$\\$\hat{\mathbi{c}}_t=\mathrm{tanh}(\mathbi{W}_c[\mathbi{h}_{t-1},\mathbi{x}_t]+\mathbi{b}_c)$};
}
{
% cell update formula
\node[formulanode,anchor=south west,text width=10em] () at ([shift={(-4\base,1.5\base)}]aux59) {记忆更新\\$\vectorn{\emph{c}}_{t}=\vectorn{\emph{f}}_t\cdot \vectorn{\emph{c}}_{t-1}+\vectorn{\emph{i}}_t\cdot \hat{\vectorn{\emph{c}}}_t$};
\node[formulanode,anchor=south west,text width=10em] () at ([shift={(-4\base,1.5\base)}]aux59) {记忆更新\\$\mathbi{c}_{t}=\mathbi{f}_t\cdot \mathbi{c}_{t-1}+\mathbi{i}_t\cdot \hat{\mathbi{c}}_t$};
}
{
% output gate formula
\node[formulanode,anchor=north west,text width=10em] () at ([shift={(-4\base,-1.5\base)}]aux29) {输出门\\$\vectorn{\emph{o}}_t=\sigma(\vectorn{\emph{W}}_o[\vectorn{\emph{h}}_{t-1},\vectorn{\emph{x}}_t]+\vectorn{\emph{b}}_o)$\\$\vectorn{\emph{h}}_{t}=\vectorn{\emph{o}}_t\cdot \mathrm{tanh}(\vectorn{\emph{c}}_{t})$};
\node[formulanode,anchor=north west,text width=10em] () at ([shift={(-4\base,-1.5\base)}]aux29) {输出门\\$\mathbi{o}_t=\sigma(\mathbi{W}_o[\mathbi{h}_{t-1},\mathbi{x}_t]+\mathbi{b}_o)$\\$\mathbi{h}_{t}=\mathbi{o}_t\cdot \mathrm{tanh}(\mathbi{c}_{t})$};
}
\end{scope}
\end{tikzpicture}
......
......@@ -28,4 +28,7 @@
\node [right of = num2,xshift= -0.7cm]{};
\node[font=\small] at ([yshift=-0.7cm,xshift=0.3cm]num12.south) {输入:4$\times$4};
\node[font=\small] at ([yshift=-1.3cm,xshift=0.3cm]num19.south) {输出:2$\times$2};
\end{tikzpicture}
\ No newline at end of file
......@@ -34,8 +34,20 @@
\node(num8_8)[num,below of = num88,xshift= -0.5cm,yshift= -0.5cm]{-1};
\node(num9_9)[num,below of = num99,xshift= -0.5cm,yshift= -0.5cm]{-1};
%\node[] (sub) at ([xshift=3.5cm,yshift=2cm]num9_9.east) {$q$:卷积核窗口的长度};
%\node[] (sub2) at ([xshift=0cm,yshift=-0.1cm]sub.south) {$k$:卷积核窗口的宽度};
%\node[] (sub3) at ([xshift=-0.2cm,yshift=-0.1cm]sub2.south) {$o$:卷积核深度\qquad \qquad };
\draw[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick] ([yshift=0.4cm]num1_1.west) -- node[att,xshift=-0.5cm]{\large q} ([yshift=-0.4cm]num3_3.west);
\draw[decorate,decoration={brace,raise=0pt,amplitude=0.3cm},black,thick] ([xshift=-0.4cm]num1.north) -- node[att,yshift=0.5cm]{\large k}([xshift=0.4cm]num7.north);
\draw[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick] ([xshift=0.4cm]num9_9.south) -- node[att,xshift=0.4cm,yshift=-0.3cm]{\large o}([xshift=0.4cm]num9.south);
\node[inner sep=2pt,fill=green!5,draw=ugreen,dotted,very thick,align=center] (sub) at ([xshift=3.8cm,yshift=2cm]num9_9.east) {
\begin{tabular}{r l}
$q$& 卷积核窗口的长度 \\
$k$& 卷积核窗口的宽度 \\
$o$& 卷积核深度
\end{tabular}};
\node[minimum width = 1.8cm] (sub) at ([xshift=-5.5cm,yshift=2cm]num9_9.east) {};
\draw[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick] ([yshift=0.4cm]num1_1.west) -- node[att,xshift=-0.5cm]{\large $q$} ([yshift=-0.4cm]num3_3.west);
\draw[decorate,decoration={brace,raise=0pt,amplitude=0.3cm},black,thick] ([xshift=-0.4cm]num1.north) -- node[att,yshift=0.5cm]{\large $k$}([xshift=0.4cm]num7.north);
\draw[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick] ([xshift=0.4cm]num9_9.south) -- node[att,xshift=0.4cm,yshift=-0.3cm]{\large $o$}([xshift=0.4cm]num9.south);
\end{tikzpicture}
\ No newline at end of file
......@@ -15,10 +15,10 @@
}
\foreach \point in {1,2}{
\draw[line width=0.5pt, ugreen!80, -latex] (l\point_0.east) -- (r2_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l\point_1.east) -- (r2_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l\point_2.east) -- (r2_2.west);
\draw[line width=0.5pt, gray!80, -latex] (l\point_3.east) -- (r2_3.west);
\draw[line width=0.9pt, ugreen!80, -latex] (l\point_0.east) -- (r2_0.west);
\draw[line width=0.9pt, orange!80, -latex] (l\point_1.east) -- (r2_1.west);
\draw[line width=0.9pt, cyan!80, -latex] (l\point_2.east) -- (r2_2.west);
\draw[line width=0.9pt, gray!80, -latex] (l\point_3.east) -- (r2_3.west);
}
\node[vuale] at (-1.5em, 1.9em) {$x_2$};
......@@ -40,10 +40,10 @@
}
\foreach \point in {1,2}{
\draw[line width=0.5pt, orange!80, -latex] (l\point_0.east) -- (r2_0.west);
\draw[line width=0.5pt, cyan!80, -latex] (l\point_1.east) -- (r2_1.west);
\draw[line width=0.5pt, orange!80, -latex] (l\point_2.east) -- (r2_2.west);
\draw[line width=0.5pt, cyan!80, -latex] (l\point_3.east) -- (r2_3.west);
\draw[line width=0.9pt, orange!80, -latex] (l\point_0.east) -- (r2_0.west);
\draw[line width=0.9pt, cyan!80, -latex] (l\point_1.east) -- (r2_1.west);
\draw[line width=0.9pt, orange!80, -latex] (l\point_2.east) -- (r2_2.west);
\draw[line width=0.9pt, cyan!80, -latex] (l\point_3.east) -- (r2_3.west);
}
\node[vuale] at (-1.5em, 1.9em) {$x_2$};
......
......@@ -45,7 +45,8 @@
\node[minimum width = 1.8cm,minimum height = 1.8cm,draw=teal,line width=0.1cm] at (0.6,2.4) {};
\fill (4,1.5) circle (2pt);
%\fill (4,1.5) circle (2pt);
\node [] at (4,1.5) {*};
\node[num] at (5,0.9){0};
\node[num] at (5.6,0.9){1};
......@@ -84,7 +85,11 @@
\node[minimum width = 0.6cm,minimum height = 0.6cm,draw=teal,line width=0.1cm] at (9,2.4) {};
\draw (1.5,-1)node{\small{输入:6$\times$6}};
\draw (5.7,-1)node{\small{卷积核:3$\times$3}};
\draw (10,-1)node{\small{输出:4$\times$4}};
\node[] (in) at (1.5,-1) {\small{输入:6$\times$6}};
\node[] at (5.7,-1) {\small{卷积核:3$\times$3}};
\node[] (out) at (10,-1) {\small{输出:4$\times$4}};
\node[font=\footnotesize,dashed,draw=teal,very thick,fill=green!5,align=center] at ([yshift=3cm,xshift=1.5cm]out.east) {*\ \ :表示\\卷积计算};
\node[] at ([yshift=-0.3cm,xshift=-2.3cm]in.east) {\ \ \ \ \ };
\end{tikzpicture}
\ No newline at end of file
......@@ -25,19 +25,28 @@
\begin{scope}
\foreach \point in {0,1,2,3,4,5}
\node[rec] (i_\point) at (0.9+\point, -0.05){};
\node[rec] (i_\point) at (0.9+\point, -0.1){};
\draw[thick] (i_0.0) -- (i_1.180);
\draw[thick] (i_1.0) -- (i_2.180);
\draw[thick] (i_2.0) -- (i_3.180);
\draw[thick] (i_3.0) -- (i_4.180);
\draw[thick] (i_4.0) -- (i_5.180);
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){$<$p$>$};
\node[anchor=north,word] (tgt_1) at ([yshift=-0.4em]i_0.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$sos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$s$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_4.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_5.south){school};
\node[anchor=north,word] (tgt_2) at ([yshift=-0.4em]i_5.south){school};
\begin{pgfonlayer}{background}
\node [draw=ugreen!30,rectangle,inner ysep=5pt,inner xsep=1.8em,rounded corners=4pt,line width=2pt,fill=ugreen!10] [fit = (tgt_1) (i_0)(tgt_2)(i_5) ] (group1_2) {};
\end{pgfonlayer}
\node[anchor=east, word] (l_0) at ([xshift=-2em,yshift=-0.5em]i_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=south, word] (l_1) at ([yshift=2em]l_0.north){\sffamily\bfnew{卷积}};
\node[anchor=south, word] (l_2) at ([yshift=2.4em]l_1.north){\sffamily\bfnew{门控}};
\node[anchor=south, word] (l_3) at ([yshift=0.06em]l_2.north){\sffamily\bfnew{线性单元}};
\foreach \point in {0,1,2}
......@@ -89,12 +98,12 @@
\node[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em](g_2_3) at (5cm+4em, 7.5cm-3em){};
\foreach \point in {0,1,2,3}
\node[rec] (i_\point) at (8+\point, -0.05){};
\node[rec] (i_\point) at (8+\point, -0.1){};
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){school};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$eos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$/s$>$};
\foreach \point in {0,1,2,3}{
\node[cir,font=\fontsize{6}{6}\selectfont,inner sep=0.8pt](c_\point) at (8.2cm+\point*2em,7.5cm-1em*\point){\bm{$\sum$}};
......@@ -131,15 +140,15 @@
\node[anchor=south,word] (src_1) at ([xshift=-2em,yshift=0.4em]r_0.north){$<$p$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_0.north){};
\node[anchor=south,word] at ([yshift=0.4em]r_1.north){上学};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$sos$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$s$>$};
\node[anchor=south,word] (src_2) at ([xshift=2em,yshift=0.4em]r_2.north){$<$p$>$};
\node[anchor=east, word] (t_1) at ([xshift=-4em,yshift=0.5em]r_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=north, word] (t_2) at ([yshift=-1em,yshift=-1em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2em,yshift=-0.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_2) at ([yshift=-2em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_4) at ([yshift=-0.06em]t_3.south){\sffamily\bfnew{线性单元}};
\node[anchor=north, word] (t_5) at ([yshift=-0.06em,yshift=1.3em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_5) at ([yshift=1.24em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_6) at ([yshift=-1.5em]t_5.south){\sffamily\bfnew{注意力模块}};
\node[cir] (o_2) at (7.95, 8.8cm){};
......@@ -158,13 +167,13 @@
\node [single arrow,minimum height=2.4em,fill=blue!30,minimum width=4pt,rotate=-90,draw, fill=blue!20] at (8.6cm+2em, 8cm) {};
\begin{pgfonlayer}{background}
\node [draw=ugreen!30,rectangle,inner ysep=5pt,inner xsep=1.3em,rounded corners=4pt,line width=2pt,fill=ugreen!10] [fit = (src_1) (src_2)(r_2) ] (group1) {};
%\node [rectangle,rounded corners=4pt,fill=mc_2_m, minimum width=3.8cm, minimum height=2.8cm] (group2) at (5.7cm, 10.7cm) {};
%\node [rectangle,rounded corners=4pt,fill=mc_2_m, minimum width=5.2cm, minimum height=3.1cm] (group3) at (3.4cm, 1.85cm) {};
%\draw [line width=2pt,draw=mc_1,fill=mc_1_m,rounded corners=4pt] ([yshift=0.4em,xshift=6em]t_6.north west) -- ([yshift=0.4em,xshift=6.3cm]t_6.north west) -- ([yshift=2.2cm,xshift=6.3cm]t_6.north west) -- ([yshift=2.2cm,xshift=9.8cm]t_6.north west) -- ([yshift=-5.4cm,xshift=9.8cm]t_6.north west) -- ([yshift=-5.4cm,xshift=-1.6em]t_6.north west)-- ([yshift=0.4em,xshift=-1.6em]t_6.north west) -- ([yshift=0.4em,xshift=6em]t_6.north west);
\node [draw=ugreen!30,rectangle,inner ysep=5pt,inner xsep=1.3em,rounded corners=4pt,line width=2pt,fill=ugreen!10] [fit = (src_1) (src_2)(r_2) ] (group1_1) {};
\node [rectangle,rounded corners=4pt,fill=mc_2_m, minimum width=3.8cm, minimum height=2.8cm] (group2) at (5.7cm, 10.7cm) {};
\node [rectangle,rounded corners=4pt,fill=mc_2_m, minimum width=5.2cm, minimum height=3.1cm] (group3) at (3.4cm, 1.85cm) {};
\draw [line width=2pt,draw=mc_1,fill=mc_1_m,rounded corners=4pt] ([yshift=0.4em,xshift=6em]t_6.north west) -- ([yshift=0.4em,xshift=6.3cm]t_6.north west) -- ([yshift=2.2cm,xshift=6.3cm]t_6.north west) -- ([yshift=2.2cm,xshift=9.8cm]t_6.north west) -- ([yshift=-5.4cm,xshift=9.8cm]t_6.north west) -- ([yshift=-5.4cm,xshift=-1.6em]t_6.north west)-- ([yshift=0.4em,xshift=-1.6em]t_6.north west) -- ([yshift=0.4em,xshift=6em]t_6.north west);
\end{pgfonlayer}
%\node [draw=mc_2!140,rectangle,rounded corners=4pt,line width=2pt,minimum width=3.8cm, minimum height=2.8cm] at (5.7cm, 10.7cm) {};
%\node [draw=mc_2!140,rectangle,rounded corners=4pt,line width=2pt,minimum width=5.2cm, minimum height=3.1cm] at (3.4cm, 1.85cm) {};
\node [draw=mc_2!140,rectangle,rounded corners=4pt,line width=2pt,minimum width=3.8cm, minimum height=2.8cm] at (5.7cm, 10.7cm) {};
\node [draw=mc_2!140,rectangle,rounded corners=4pt,line width=2pt,minimum width=5.2cm, minimum height=3.1cm] at (3.4cm, 1.85cm) {};
\end{scope}
\end{tikzpicture}
\ No newline at end of file
......@@ -25,7 +25,7 @@
\begin{scope}
\foreach \point in {0,1,2,3,4,5}
\node[rec] (i_\point) at (0.9+\point, -0.05){};
\node[rec] (i_\point) at (0.9+\point, -0.1){};
\draw[thick] (i_0.0) -- (i_1.180);
\draw[thick] (i_1.0) -- (i_2.180);
\draw[thick] (i_2.0) -- (i_3.180);
......@@ -34,11 +34,15 @@
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$sos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$s$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_4.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_5.south){school};
\node[anchor=east, word] (l_0) at ([xshift=-2em,yshift=-0.5em]i_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=south, word] (l_1) at ([yshift=2em]l_0.north){\sffamily\bfnew{卷积}};
\node[anchor=south, word] (l_2) at ([yshift=2.4em]l_1.north){\sffamily\bfnew{门控}};
\node[anchor=south, word] (l_3) at ([yshift=0.06em]l_2.north){\sffamily\bfnew{线性单元}};
\foreach \point in {0,1,2}
\draw[thick,fill=blue!20] (5.9-\point,0.4) -- (4.9-\point,1.5) -- (3.9-\point,0.4) -- (5.9-\point,0.4);
......@@ -89,12 +93,12 @@
\node[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em](g_2_3) at (5cm+4em, 7.5cm-3em){};
\foreach \point in {0,1,2,3}
\node[rec] (i_\point) at (8+\point, -0.05){};
\node[rec] (i_\point) at (8+\point, -0.1){};
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){school};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$eos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$/s$>$};
\foreach \point in {0,1,2,3}{
\node[cir,font=\fontsize{6}{6}\selectfont,inner sep=0.8pt](c_\point) at (8.2cm+\point*2em,7.5cm-1em*\point){\bm{$\sum$}};
......@@ -131,15 +135,15 @@
\node[anchor=south,word] (src_1) at ([xshift=-2em,yshift=0.4em]r_0.north){$<$p$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_0.north){};
\node[anchor=south,word] at ([yshift=0.4em]r_1.north){上学};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$sos$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$s$>$};
\node[anchor=south,word] (src_2) at ([xshift=2em,yshift=0.4em]r_2.north){$<$p$>$};
\node[anchor=east, word] (t_1) at ([xshift=-4em,yshift=0.5em]r_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=north, word] (t_2) at ([yshift=-1em,yshift=-1em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2em,yshift=-0.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_2) at ([yshift=-2em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_4) at ([yshift=-0.06em]t_3.south){\sffamily\bfnew{线性单元}};
\node[anchor=north, word] (t_5) at ([yshift=-0.06em,yshift=1.3em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_5) at ([yshift=1.24em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_6) at ([yshift=-1.5em]t_5.south){\sffamily\bfnew{注意力模块}};
\node[cir] (o_2) at (7.95, 8.8cm){};
......
......@@ -25,7 +25,7 @@
\begin{scope}
\foreach \point in {0,1,2,3,4,5}
\node[rec] (i_\point) at (0.9+\point, -0.05){};
\node[rec] (i_\point) at (0.9+\point, -0.1){};
\draw[thick] (i_0.0) -- (i_1.180);
\draw[thick] (i_1.0) -- (i_2.180);
\draw[thick] (i_2.0) -- (i_3.180);
......@@ -34,11 +34,16 @@
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){$<$p$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$sos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){$<$s$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_4.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_5.south){school};
\node[anchor=east, word] (l_0) at ([xshift=-2em,yshift=-0.5em]i_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=south, word] (l_1) at ([yshift=2em]l_0.north){\sffamily\bfnew{卷积}};
\node[anchor=south, word] (l_2) at ([yshift=2.4em]l_1.north){\sffamily\bfnew{门控}};
\node[anchor=south, word] (l_3) at ([yshift=0.06em]l_2.north){\sffamily\bfnew{线性单元}};
\foreach \point in {0,1,2}
\draw[thick,fill=blue!20] (5.9-\point,0.4) -- (4.9-\point,1.5) -- (3.9-\point,0.4) -- (5.9-\point,0.4);
......@@ -89,12 +94,12 @@
\node[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em](g_2_3) at (5cm+4em, 7.5cm-3em){};
\foreach \point in {0,1,2,3}
\node[rec] (i_\point) at (8+\point, -0.05){};
\node[rec] (i_\point) at (8+\point, -0.1){};
\node[anchor=north,word] at ([yshift=-0.4em]i_0.south){go};
\node[anchor=north,word] at ([yshift=-0.4em]i_1.south){to};
\node[anchor=north,word] at ([yshift=-0.4em]i_2.south){school};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$eos$>$};
\node[anchor=north,word] at ([yshift=-0.4em]i_3.south){$<$/s$>$};
\foreach \point in {0,1,2,3}{
\node[cir,font=\fontsize{6}{6}\selectfont,inner sep=0.8pt](c_\point) at (8.2cm+\point*2em,7.5cm-1em*\point){\bm{$\sum$}};
......@@ -131,15 +136,15 @@
\node[anchor=south,word] (src_1) at ([xshift=-2em,yshift=0.4em]r_0.north){$<$p$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_0.north){};
\node[anchor=south,word] at ([yshift=0.4em]r_1.north){上学};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$sos$>$};
\node[anchor=south,word] at ([yshift=0.4em]r_2.north){$<$s$>$};
\node[anchor=south,word] (src_2) at ([xshift=2em,yshift=0.4em]r_2.north){$<$p$>$};
\node[anchor=east, word] (t_1) at ([xshift=-4em,yshift=0.5em]r_0.west){\sffamily\bfnew{词嵌入}};
\node[anchor=north, word] (t_2) at ([yshift=-1em,yshift=-1em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2em,yshift=-0.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_2) at ([yshift=-2em]t_1.south){\sffamily\bfnew{卷积}};
\node[anchor=north, word] (t_3) at ([yshift=-2.8em]t_2.south){\sffamily\bfnew{门控}};
\node[anchor=north, word] (t_4) at ([yshift=-0.06em]t_3.south){\sffamily\bfnew{线性单元}};
\node[anchor=north, word] (t_5) at ([yshift=-0.06em,yshift=1.3em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_5) at ([yshift=1.24em]t_4.south){\sffamily\bfnew{}};
\node[anchor=north, word] (t_6) at ([yshift=-1.5em]t_5.south){\sffamily\bfnew{注意力模块}};
\node[cir] (o_2) at (7.95, 8.8cm){};
......
......@@ -25,9 +25,12 @@
\node[data,inner sep=2pt,fill=cyan!40] at (14.4em,2.4em) {19};
\node[data,inner sep=2pt] at (16em,2.4em) {25};
\node[font=\footnotesize] at (1.6em,4.8em) {输入};
\node[font=\footnotesize] (in) at (1.6em,4.8em) {输入};
\node[font=\footnotesize] at (8.8em,4.8em) {卷积核};
\node[font=\footnotesize] at (15.2em,4.8em) {输出};
\node[font=\footnotesize] (out) at (15.2em,4.8em) {输出};
\node[font=\footnotesize,dashed,draw=cyan,very thick,fill=cyan!5,align=center] at ([yshift=-0.3cm,xshift=1.8cm]out.east) {*\ \ :表示\\卷积计算};
\node[] at ([yshift=-0.3cm,xshift=-2.3cm]in.east) {\ \ \ \ \ };
\node at (5.6em, 1.6em) {*};
\node at (12em, 1.6em) {=};
......
......@@ -28,4 +28,7 @@
\node [right of = num20,xshift= 0.7cm]{};
\node[font=\small] at ([yshift=-0.7cm,xshift=0.3cm]num12.south) {输入:4$\times$4};
\node[font=\small] at ([yshift=-1.3cm,xshift=0.3cm]num19.south) {输出:2$\times$2};
\end{tikzpicture}
\ No newline at end of file
......@@ -77,7 +77,8 @@
\node[minimum width = 1.8cm,minimum height = 1.8cm,draw=teal,line width=0.1cm] at (0,3) {};
\node[minimum width = 1.8cm,minimum height = 1.8cm,draw=orange!80,line width=0.08cm] at (0.6,2.4) {};
\fill (4.55,1.5) circle (2pt);
%\fill (4.55,1.5) circle (2pt);
\node [] at (4.55,1.5) {*};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node[num] at (5.5,0.9){0};
......@@ -140,7 +141,13 @@
\node[minimum width = 0.6cm,minimum height = 0.6cm,draw=teal,line width=0.1cm] at (8.4,3) {};
\node[minimum width = 0.6cm,minimum height = 0.6cm,draw=orange!80,line width=0.08cm] at (9,2.4) {};
\draw (1.5,-1.5)node{\small{输入:8$\times$8(填充后)}};
\draw (5.7,-1.5)node{\small{卷积核:3$\times$3}};
\draw (10,-1.5)node{\small{输出:6$\times$6}};
%\draw (1.5,-1.5)node{\small{输入:8$\times$8(填充后)}};
%\draw (5.7,-1.5)node{\small{卷积核:3$\times$3}};
%\draw (10,-1.5)node{\small{输出:6$\times$6}};
\node[] (in) at (1.5,-1.5) {\small{输入:8$\times$8(填充后)}};
\node[] at (5.7,-1.5) {\small{卷积核:3$\times$3}};
\node[] (out) at (10,-1.5) {\small{输出:6$\times$6}};
\node[font=\footnotesize,dashed,draw=teal,very thick,fill=green!5,align=center] at ([yshift=4cm,xshift=1.8cm]out.east) {*\ \ :表示\\卷积计算};
\node[] at ([yshift=-0.3cm,xshift=-2.3cm]in.east) {\ \ \ \ \ };
\end{tikzpicture}
\ No newline at end of file
......@@ -23,6 +23,13 @@
\draw[fill=blue!40,draw=blue!40] ([yshift=0.05em]a4.north) -- ([yshift=0.05em]a6.north) -- ([yshift=-0.05em]b4.south) -- ([yshift=0.05em]a4.north);
\draw[fill=blue!50,draw=blue!50] ([yshift=0.05em]a5.north) -- ([yshift=0.05em]a7.north) -- ([yshift=-0.05em]b5.south) -- ([yshift=0.05em]a5.north);
\node[inner sep=2pt,word,fill=blue!5,draw=blue!60,dotted,very thick,align=center,font=\scriptsize] (sub) at ([xshift=2.3cm,yshift=-0.8cm]b5.east) {
\begin{tabular}{r l}
$<$p$>$& 填充 \\
$<$sos$>$& 表示序列的开始 \\
$<$eos$>$& 表示序列的终止
\end{tabular}};
\node[] at ([xshift=-6em]a1.west) {};
\end{tikzpicture}
\ No newline at end of file
......@@ -43,6 +43,15 @@
\node[word] (w6) at ([yshift=-\bd]w5) {日子};
\node[word] (w7) at ([yshift=-\bd]w6) {};
\node[word] (w8) at ([yshift=-\bd]w7) {$<$p$>$};
\node[inner sep=2pt,word,fill=green!5,draw=ugreen,dotted,very thick,minimum width=6em,align=center,minimum height=4em] (sub) at ([xshift=11cm,yshift=-0.1cm]w1.east) {
\begin{tabular}{r l}
$<$p$>$& 填充 \\
$\sigma$& sigmoid函数 \\
$\otimes$& 按位乘运算 \\
*: &卷积计算
\end{tabular}};
% $<$p$>$:填充 \\ $\sigma$:sigmoid函数 \\ $\otimes$:按位乘运算 \\ *:卷积计算
\node[circle, draw, minimum size=0.7em, inner sep=0.5pt,font=\footnotesize,fill=yellow!40] (c1) at ([yshift=1.2em]b.north) {$\sigma$};
\node[circle, draw, minimum size=0.7em, inner sep=0.5pt,font=\footnotesize,fill=yellow!40] (c2) at ([xshift=1.5em]b.east) {};
......
......@@ -17,19 +17,19 @@
}
\foreach \point in {0,1,2}{
\draw[line width=0.5pt, ugreen!80, -latex] (l1_\point.east) -- (r2_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l1_\point.east) -- (r2_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l1_\point.east) -- (r2_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l2_\point.east) -- (r2_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l2_\point.east) -- (r2_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l2_\point.east) -- (r2_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l2_\point.east) -- (r3_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l2_\point.east) -- (r3_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l2_\point.east) -- (r3_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l3_\point.east) -- (r3_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l3_\point.east) -- (r3_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l3_\point.east) -- (r3_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l1_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r2_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l1_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r2_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l1_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r2_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l2_\point.east) -- ([xshift=0em,yshift=0.1em]r2_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l2_\point.east) -- ([xshift=0em,yshift=0.1em]r2_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l2_\point.east) -- ([xshift=0em,yshift=0.1em]r2_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l2_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r3_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l2_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r3_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l2_\point.east) -- ([xshift=-0.1em,yshift=-0.1em]r3_2.west);
\draw[line width=0.5pt, ugreen!80, -latex] (l3_\point.east) -- ([xshift=0em,yshift=0.1em]r3_0.west);
\draw[line width=0.5pt, orange!80, -latex] (l3_\point.east) -- ([xshift=0em,yshift=0.1em]r3_1.west);
\draw[line width=0.5pt, cyan!80, -latex] (l3_\point.east) -- ([xshift=0em,yshift=0.1em]r3_2.west);
}
\node[vuale] at ([xshift=-0.9em]l1_1.west) {$x_3$};
......
......@@ -52,59 +52,59 @@
\node(num4_9)[num,right of = num4_8,xshift = 1.2cm]{\textbf4};
\node(num4_10)[num,right of = num4_9,xshift = 1.2cm, fill = blue!40]{\textbf0};
\draw [->, thick](num1_0.north)--(num2_1.south);
\draw [->, thick](num2_0.north)--(num3_1.south);
\draw [->, thick](num3_0.north)--(num4_1.south);
\draw [->, thick](num1_1.north)--(num2_2.south);
\draw [->, thick](num2_1.north)--(num3_2.south);
\draw [->, thick](num3_1.north)--(num4_2.south);
\draw [->, thick, color = blue!60](num1_2.north)--(num2_3.south);
\draw [->, thick](num2_2.north)--(num3_3.south);
\draw [->, thick](num3_2.north)--(num4_3.south);
\draw [->, thick, color = blue!60](num1_3.north)--(num2_4.south);
\draw [->, thick, color = blue!60](num2_3.north)--(num3_4.south);
\draw [->, thick](num3_3.north)--(num4_4.south);
\draw [->, thick, color = blue!60](num1_4.north)--(num2_5.south);
\draw [->, thick, color = blue!60](num2_4.north)--(num3_5.south);
\draw [->, thick, color = blue!60](num3_4.north)--(num4_5.south);
\draw [->, thick, color = blue!60](num1_5.north)--(num2_6.south);
\draw [->, thick, color = blue!60](num2_5.north)--(num3_6.south);
\draw [->, thick](num3_5.north)--(num4_6.south);
\draw [->, thick, color = blue!60](num1_6.north)--(num2_7.south);
\draw [->, thick](num2_6.north)--(num3_7.south);
\draw [->, thick](num3_6.north)--(num4_7.south);
\draw [->, thick](num1_7.north)--(num2_8.south);
\draw [->, thick](num2_7.north)--(num3_8.south);
\draw [->, thick](num3_7.north)--(num4_8.south);
\draw [->, thick](num1_8.north)--(num2_9.south);
\draw [->, thick](num2_8.north)--(num3_9.south);
\draw [->, thick](num3_8.north)--(num4_9.south);
\draw [->, thick](num1_0.north)--([xshift=-0.1em,yshift=-0.1em]num2_1.south);
\draw [->, thick](num2_0.north)--([xshift=-0.1em,yshift=-0.1em]num3_1.south);
\draw [->, thick](num3_0.north)--([xshift=-0.1em,yshift=-0.1em]num4_1.south);
\draw [->, thick](num1_1.north)--([xshift=-0.1em,yshift=-0.1em]num2_2.south);
\draw [->, thick](num2_1.north)--([xshift=-0.1em,yshift=-0.1em]num3_2.south);
\draw [->, thick](num3_1.north)--([xshift=-0.1em,yshift=-0.1em]num4_2.south);
\draw [->, thick, color = blue!60](num1_2.north)--([xshift=-0.1em,yshift=-0.1em]num2_3.south);
\draw [->, thick](num2_2.north)--([xshift=-0.1em,yshift=-0.1em]num3_3.south);
\draw [->, thick](num3_2.north)--([xshift=-0.1em,yshift=-0.1em]num4_3.south);
\draw [->, thick, color = blue!60](num1_3.north)--([xshift=-0.1em,yshift=-0.1em]num2_4.south);
\draw [->, thick, color = blue!60](num2_3.north)--([xshift=-0.1em,yshift=-0.1em]num3_4.south);
\draw [->, thick](num3_3.north)--([xshift=-0.1em,yshift=-0.1em]num4_4.south);
\draw [->, thick, color = blue!60](num1_4.north)--([xshift=-0.1em,yshift=-0.1em]num2_5.south);
\draw [->, thick, color = blue!60](num2_4.north)--([xshift=-0.1em,yshift=-0.1em]num3_5.south);
\draw [->, thick, color = blue!60](num3_4.north)--([xshift=-0.1em,yshift=-0.1em]num4_5.south);
\draw [->, thick, color = blue!60](num1_5.north)--([xshift=-0.1em,yshift=-0.1em]num2_6.south);
\draw [->, thick, color = blue!60](num2_5.north)--([xshift=-0.1em,yshift=-0.1em]num3_6.south);
\draw [->, thick](num3_5.north)--([xshift=-0.1em,yshift=-0.1em]num4_6.south);
\draw [->, thick, color = blue!60](num1_6.north)--([xshift=-0.1em,yshift=-0.1em]num2_7.south);
\draw [->, thick](num2_6.north)--([xshift=-0.1em,yshift=-0.1em]num3_7.south);
\draw [->, thick](num3_6.north)--([xshift=-0.1em,yshift=-0.1em]num4_7.south);
\draw [->, thick](num1_7.north)--([xshift=-0.1em,yshift=-0.1em]num2_8.south);
\draw [->, thick](num2_7.north)--([xshift=-0.1em,yshift=-0.1em]num3_8.south);
\draw [->, thick](num3_7.north)--([xshift=-0.1em,yshift=-0.1em]num4_8.south);
\draw [->, thick](num1_8.north)--([xshift=-0.1em,yshift=-0.1em]num2_9.south);
\draw [->, thick](num2_8.north)--([xshift=-0.1em,yshift=-0.1em]num3_9.south);
\draw [->, thick](num3_8.north)--([xshift=-0.1em,yshift=-0.1em]num4_9.south);
\draw [->, thick](num1_2.north)--(num2_1.south);
\draw [->, thick](num2_2.north)--(num3_1.south);
\draw [->, thick](num3_2.north)--(num4_1.south);
\draw [->, thick](num1_3.north)--(num2_2.south);
\draw [->, thick](num2_3.north)--(num3_2.south);
\draw [->, thick](num3_3.north)--(num4_2.south);
\draw [->, thick, color = blue!60](num1_4.north)--(num2_3.south);
\draw [->, thick](num2_4.north)--(num3_3.south);
\draw [->, thick](num3_4.north)--(num4_3.south);
\draw [->, thick, color = blue!60](num1_5.north)--(num2_4.south);
\draw [->, thick, color = blue!60](num2_5.north)--(num3_4.south);
\draw [->, thick](num3_5.north)--(num4_4.south);
\draw [->, thick, color = blue!60](num1_6.north)--(num2_5.south);
\draw [->, thick, color = blue!60](num2_6.north)--(num3_5.south);
\draw [->, thick, color = blue!60](num3_6.north)--(num4_5.south);
\draw [->, thick, color = blue!60](num1_7.north)--(num2_6.south);
\draw [->, thick, color = blue!60](num2_7.north)--(num3_6.south);
\draw [->, thick](num3_7.north)--(num4_6.south);
\draw [->, thick, color = blue!60](num1_8.north)--(num2_7.south);
\draw [->, thick](num2_8.north)--(num3_7.south);
\draw [->, thick](num3_8.north)--(num4_7.south);
\draw [->, thick](num1_9.north)--(num2_8.south);
\draw [->, thick](num2_9.north)--(num3_8.south);
\draw [->, thick](num3_9.north)--(num4_8.south);
\draw [->, thick](num1_10.north)--(num2_9.south);
\draw [->, thick](num2_10.north)--(num3_9.south);
\draw [->, thick](num3_10.north)--(num4_9.south);
\draw [->, thick](num1_2.north)--([xshift=0.1em,yshift=-0.1em]num2_1.south);
\draw [->, thick](num2_2.north)--([xshift=0.1em,yshift=-0.1em]num3_1.south);
\draw [->, thick](num3_2.north)--([xshift=0.1em,yshift=-0.1em]num4_1.south);
\draw [->, thick](num1_3.north)--([xshift=0.1em,yshift=-0.1em]num2_2.south);
\draw [->, thick](num2_3.north)--([xshift=0.1em,yshift=-0.1em]num3_2.south);
\draw [->, thick](num3_3.north)--([xshift=0.1em,yshift=-0.1em]num4_2.south);
\draw [->, thick, color = blue!60](num1_4.north)--([xshift=0.1em,yshift=-0.1em]num2_3.south);
\draw [->, thick](num2_4.north)--([xshift=0.1em,yshift=-0.1em]num3_3.south);
\draw [->, thick](num3_4.north)--([xshift=0.1em,yshift=-0.1em]num4_3.south);
\draw [->, thick, color = blue!60](num1_5.north)--([xshift=0.1em,yshift=-0.1em]num2_4.south);
\draw [->, thick, color = blue!60](num2_5.north)--([xshift=0.1em,yshift=-0.1em]num3_4.south);
\draw [->, thick](num3_5.north)--([xshift=0.1em,yshift=-0.1em]num4_4.south);
\draw [->, thick, color = blue!60](num1_6.north)--([xshift=0.1em,yshift=-0.1em]num2_5.south);
\draw [->, thick, color = blue!60](num2_6.north)--([xshift=0.1em,yshift=-0.1em]num3_5.south);
\draw [->, thick, color = blue!60](num3_6.north)--([xshift=0.1em,yshift=-0.1em]num4_5.south);
\draw [->, thick, color = blue!60](num1_7.north)--([xshift=0.1em,yshift=-0.1em]num2_6.south);
\draw [->, thick, color = blue!60](num2_7.north)--([xshift=0.1em,yshift=-0.1em]num3_6.south);
\draw [->, thick](num3_7.north)--([xshift=0.1em,yshift=-0.1em]num4_6.south);
\draw [->, thick, color = blue!60](num1_8.north)--([xshift=0.1em,yshift=-0.1em]num2_7.south);
\draw [->, thick](num2_8.north)--([xshift=0.1em,yshift=-0.1em]num3_7.south);
\draw [->, thick](num3_8.north)--([xshift=0.1em,yshift=-0.1em]num4_7.south);
\draw [->, thick](num1_9.north)--([xshift=0.1em,yshift=-0.1em]num2_8.south);
\draw [->, thick](num2_9.north)--([xshift=0.1em,yshift=-0.1em]num3_8.south);
\draw [->, thick](num3_9.north)--([xshift=0.1em,yshift=-0.1em]num4_8.south);
\draw [->, thick](num1_10.north)--([xshift=0.1em,yshift=-0.1em]num2_9.south);
\draw [->, thick](num2_10.north)--([xshift=0.1em,yshift=-0.1em]num3_9.south);
\draw [->, thick](num3_10.north)--([xshift=0.1em,yshift=-0.1em]num4_9.south);
\end{tikzpicture}
\ No newline at end of file
%\newlength{\bc}
\setlength{\bc}{0.4cm}
\begin{tikzpicture}
\begin{scope}
......@@ -58,8 +59,9 @@
\draw[-latex] (c2.east) -- ([xshift=0.2cm, yshift=-0.2cm]c2.east);
%%%%%%%%%%%%%%%%%%%%%
\node[word] (sub) at ([xshift=9.5*\bc,yshift=3*\bc]w1) {$O$:卷积核大小};
\node[word] (sub2) at ([yshift=-0.5*\bc]sub.south) {$N$:卷积核数量};
\node[word] (sub) at ([xshift=9.5*\bc,yshift=3.5*\bc]w1) {$O$\ \ :输入通道数};
\node[word] (sub2) at ([yshift=-0.5*\bc]sub.south) {$N$\ \ :卷积核数量};
\node[word] (sub3) at ([xshift=-1.35em,yshift=-0.5*\bc]sub2.south) {$<$p$>$:填充};
\end{scope}
......
%\newlength{\bc}
\setlength{\bc}{0.4cm}
\begin{tikzpicture}
\begin{scope}
%\tikzstyle{every node}=[scale=0.8]
\tikzstyle{line} = [dash pattern=on 2pt off 1pt,line width=0.5pt]
\tikzstyle{line} = [dash pattern=on 2pt off 1pt,line width=0.6pt]
\tikzstyle{cir} = [thin,fill=blue!8,draw,circle,minimum size =0.5em,drop shadow={shadow xshift=0.15em, shadow yshift=-0.1em}]
\tikzstyle{word} = [inner sep=0pt, font=\footnotesize,minimum height=\bc]
\draw[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[ugreen!60,step=\bc,xshift=0.3cm,yshift=0.5cm,gray] (0cm,0cm) grid (0cm+6*\bc,0cm+9*\bc);
%\draw[line width=0.7pt,xshift=0.3cm,yshift=0.5cm] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[red!60,line width=2pt,xshift=0.3cm,yshift=0.5cm] (0cm,0cm+2*\bc) rectangle (0cm+6*\bc,0cm+4*\bc);
\draw[thick,fill=blue!8,line width=0.2pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[thick,fill=blue!8,line width=0.6pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[step=\bc,gray] (0cm,0cm) grid (0cm+6*\bc,0cm+9*\bc);
%\draw[line width=0.7pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[red!60,line width=2pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+2*\bc);
......@@ -21,31 +22,31 @@
\draw[red!60,line width=2pt] (0cm,0cm+7*\bc) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw[fill=blue!8,xshift=5.0cm,yshift=1.3cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[fill=blue!8,xshift=5.0cm,yshift=1.3cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[step=\bc,gray,xshift=5.0cm,yshift=1.3cm] (0cm,0cm) grid (0cm+1*\bc,0cm+6*\bc);
%\draw[xshift=5.0cm,yshift=1.3cm,line width=0.7pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[ugreen!60,line width=2pt,xshift=5.0cm,yshift=1.3cm] (0cm,0cm+2*\bc) rectangle (0cm+1*\bc,0cm+3*\bc);
\draw [gray,fill=blue!8](8cm,2.6cm) -- (8.4cm, 2.6cm) -- (9cm,1cm) -- (8.6cm, 1cm) -- (8cm,2.6cm);
\draw [gray,fill=blue!8,line width=0.6pt](8cm,2.6cm) -- (8.4cm, 2.6cm) -- (9cm,1cm) -- (8.6cm, 1cm) -- (8cm,2.6cm);
\draw [gray](8.15cm,2.2cm) -- (8.55cm,2.2cm);
\draw [gray](8.3cm,1.8cm) -- (8.7cm,1.8cm);
\draw [gray](8.45cm,1.4cm) -- (8.85cm,1.4cm);
\draw [gray,fill=blue!8](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.4cm) -- (11.3cm, 1.4cm) -- (11cm,2.2cm);
\draw [gray,fill=blue!8,line width=0.6pt](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.4cm) -- (11.3cm, 1.4cm) -- (11cm,2.2cm);
\draw [gray](11.15cm,1.8cm) -- (11.55cm,1.8cm);
\draw[ugreen!60,line] ([xshift=5.0cm,yshift=1.3cm]0cm+1*\bc,0cm+6*\bc) -- (8cm,2.6cm);
\draw[ugreen!60,line] ([xshift=5.0cm,yshift=1.3cm]0cm+1*\bc,0cm) -- (8.15cm,2.2cm);
\draw[fill=blue!8,xshift=5.2cm,yshift=1.0cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[fill=blue!8,xshift=5.2cm,yshift=1.0cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[step=\bc,gray,xshift=5.2cm,yshift=1.0cm] (0cm,0cm) grid (0cm+1*\bc,0cm+6*\bc);
%\draw[line width=0.7pt,xshift=5.2cm,yshift=1.0cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw[fill=blue!8,xshift=5.4cm,yshift=0.3cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[fill=blue!8,xshift=5.4cm,yshift=0.3cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[step=\bc,gray,xshift=5.4cm,yshift=0.3cm] (0cm,0cm) grid (0cm+1*\bc,0cm+7*\bc);
%\draw[line width=0.7pt,xshift=5.4cm,yshift=0.3cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[fill=blue!8,xshift=5.6cm,yshift=0cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[fill=blue!8,xshift=5.6cm,yshift=0cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[step=\bc,gray,xshift=5.6cm,yshift=0cm] (0cm,0cm) grid (0cm+1*\bc,0cm+7*\bc);
%\draw[line width=0.7pt,xshift=5.6cm,yshift=0cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw[red!60,line width=2pt,xshift=5.6cm,yshift=0cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+1*\bc);
......@@ -86,7 +87,7 @@
%\draw [thick] (10cm, -0.3cm) -- (10cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{Fully connected layer \\ with dropout and \\ softmax output} (11.7cm,-0.5cm) -- (11.7cm, -0.3cm);
\draw [thick] (0cm, -0.3cm) -- (0cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{维度大小为 $m \times k$ \\ 的静态与非静态通道\\的句子表示} (2.4cm,-0.5cm) -- (2.4cm, -0.3cm);
\draw [thick] (3.6cm, -0.3cm) -- (3.6cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{具有多个不同大小\\的卷积核和特征图\\的卷积层} (6cm,-0.5cm) -- (6cm, -0.3cm);
\draw [thick] (7.2cm, -0.3cm) -- (7.2cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{Max-over-time\\ pooling} (9cm,-0.5cm) -- (9cm, -0.3cm);
\draw [thick] (7.2cm, -0.3cm) -- (7.2cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{最大池化} (9cm,-0.5cm) -- (9cm, -0.3cm);
\draw [thick] (10cm, -0.3cm) -- (10cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{带有dropout\\和softmax输出\\的全连接层} (11.7cm,-0.5cm) -- (11.7cm, -0.3cm);
......
......@@ -16,6 +16,7 @@
\renewcommand\figurename{}%将figure改为图
\renewcommand\tablename{}%将figure改为图
\chapterimage{fig-NEU-2.jpg} % Chapter heading image
\newlength{\bc}
%----------------------------------------------------------------------------------------
% CHAPTER 11
......@@ -175,8 +176,8 @@
\begin{figure}[htp]
\centering
%\input{./Chapter11/Figures/figure-f }
\subfigure[O(n)]{\input{./Chapter11/Figures/figure-structural-comparison-a}}
\subfigure[O(n/k)]{\input{./Chapter11/Figures/figure-structural-comparison-b}}
\subfigure[$O(n)$]{\input{./Chapter11/Figures/figure-structural-comparison-a}}
\subfigure[$O(n/k)$]{\input{./Chapter11/Figures/figure-structural-comparison-b}}
\caption{串行及层级结构对比}
\label{fig:11-9}
\end{figure}
......@@ -234,7 +235,7 @@
% 图12.
\begin{figure}[htp]
\centering
\input{./Chapter11/Figures/figure-fairseq-1}
\input{./Chapter11/Figures/figure-fairseq-0}
\caption{ConvS2S结构}
\label{fig:11-12}
\end{figure}
......@@ -265,7 +266,7 @@
\begin{figure}[htp]
\centering
\input{./Chapter11/Figures/figure-fairseq-2}
\caption{门控卷积网络机制在模型中的位置}
\caption{门控卷积网络机制在模型中的位置(黄色背景框部分)}
\label{fig:11-13}
\end{figure}
%----------------------------------------------
......@@ -284,8 +285,8 @@
\parinterval\ref{fig:11-14}是单层门控卷积网络的基本结构,$\mathbi{X}\in \mathbb{R}^{m\times d}$为单层网络的输入,$\mathbi{Y} \in \mathbb{R}^{m \times d}$为单层网络的输出,网络结构主要包括卷积计算和GLU非线性单元两部分。如图所示,形式上,卷积操作可以分成两部分,分别使用两个卷积核来得到两个卷积结果:
\begin{eqnarray}
\mathbi{A} = \mathbi{X} \cdot \mathbi{W} + \mathbi{b}_\mathbi{W} \nonumber \\
\mathbi{B} = \mathbi{X} \cdot \mathbi{V} + \mathbi{b}_\mathbi{V} \ \
\mathbi{A} = \mathbi{X} * \mathbi{W} + \mathbi{b}_\mathbi{W} \nonumber \\
\mathbi{B} = \mathbi{X} * \mathbi{V} + \mathbi{b}_\mathbi{V} \ \
\label{eq:11-1}
\end{eqnarray}
......@@ -355,19 +356,19 @@ x_{l+1} = x_l + F (x_l)
\begin{figure}[htp]
\centering
\input{./Chapter11/Figures/figure-fairseq-3}
\caption{多跳自注意力机制在模型中的位置}
\caption{多跳自注意力机制在模型中的位置(蓝色背景框部分)}
\label{fig:11-16}
\end{figure}
%----------------------------------------------
\parinterval 注意力机制早在基于循环神经网络的翻译模型中被广泛使用\upcite{bahdanau2014neural},用于避免循环神经网络将源语言序列压缩成一个固定维度的向量表示带来的信息损失。另一方面,注意力同样能够帮助解码端区分源语言中不同位置词对当前解码词的贡献权重,其具体的计算过程如下:
\begin{eqnarray}
\mathbi{C}_j = \sum_i \alpha_{i,j} \mathbi{h}_i \\
\alpha_{i,j} = \frac{ \textrm{exp}(a (\mathbi{s}_{j-1},\mathbi{h}_i)) }{\sum_{i'} \textrm{exp}(a(\mathbi{s}_{j-1},\mathbi{h}_{i'}))}
\mathbi{C}_j &=& \sum_i \alpha_{i,j} \mathbi{h}_i \\
\alpha_{i,j} &=& \frac{ \textrm{exp}(a (\mathbi{s}_{j-1},\mathbi{h}_i)) }{\sum_{i'} \textrm{exp}(a(\mathbi{s}_{j-1},\mathbi{h}_{i'}))}
\label{eq:11-5}
\end{eqnarray}
\noindent 其中$\mathbi{h}_i$表示源语端第$i$个位置的隐层状态,$\mathbi{s}_j$表示目标端第$j$个位置的隐层状态。给定$\mathbi{s}_j$$\mathbi{h}_i$,注意力机制通过函数a($\cdot$)计算目标语言表示$\mathbi{s}_j$与源语言表示$\mathbi{h}_i$之间的注意力权重$\alpha_{i,j}$,通过加权平均得到当前目标端位置所需的上下文表示$\mathbi{C}_j$。其中a($\cdot$)的具体计算方式在{\chapterten}\ref{sec:10.4.2}已经详细讨论。
\noindent 其中$\mathbi{h}_i$表示源语端第$i$个位置的隐层状态,$\mathbi{s}_j$表示目标端第$j$个位置的隐层状态。给定$\mathbi{s}_j$$\mathbi{h}_i$,注意力机制通过函数a($\cdot$)计算目标语言表示$\mathbi{s}_j$与源语言表示$\mathbi{h}_i$之间的注意力权重$\alpha_{i,j}$,通过加权平均得到当前目标端位置所需的上下文表示$\mathbi{C}_j$。其中a($\cdot$)的具体计算方式在{\chapterten}已经详细讨论。
\parinterval 对比基于循环神经网络的机器翻译模型(GNMT)仅在解码端的最底层采用注意力机制,在ConvS2S模型中,解码端的每一层中都分别引入了注意力机制,同时通过残差连接的方式将结果作用于上层网络的计算,因此称之为{\small\bfnew{ 多跳注意力}}(Multi-step Attention)。 其中ConvS2S模型选取向量乘的方式作为a($\cdot$)函数具体的数学描述为:
\begin{eqnarray}
......@@ -407,7 +408,7 @@ x_{l+1} = x_l + F (x_l)
\parinterval ConvS2S同样有针对性的应用了很多工程方面的调整,主要包括:
\begin{itemize}
\item ConvS2S使用了{\small\bfnew{Nesterov加速梯度下降法}}(NAG),动量累计的系数设置为0.99,当梯度范数超过0.1时重新进行规范化\upcite{Sutskever2013OnTI}
\item ConvS2S使用了{\small\bfnew{Nesterov加速梯度下降法}}(Nesterov Accelerated Gradient,NAG),动量累计的系数设置为0.99,当梯度范数超过0.1时重新进行规范化\upcite{Sutskever2013OnTI}
\item ConvS2S中设置学习率为0.25,每当模型在校验集上的困惑度不再下降时,便在每轮的训练后将学习率降低一个数量级,直至学习率小于一定的阈值(如0.0004)。
\end{itemize}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论