Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mtbookv2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
mtbookv2
Commits
89d4bea0
Commit
89d4bea0
authored
Jan 14, 2021
by
zengxin
Browse files
Options
Browse Files
Download
Plain Diff
合并分支 'zengxin' 到 'caorunzhe'
Zengxin 查看合并请求
!903
parents
47328ec5
1ee2e81f
隐藏空白字符变更
内嵌
并排
正在显示
51 个修改的文件
包含
368 行增加
和
364 行删除
+368
-364
Chapter10/Figures/figure-3-base-problom-of-p.tex
+6
-6
Chapter10/Figures/figure-a-working-example-of-neural-machine-translation.tex
+3
-3
Chapter10/Figures/figure-attention-of-source-and-target-words.tex
+5
-5
Chapter10/Figures/figure-beam-search-process.tex
+3
-3
Chapter10/Figures/figure-bi-rnn.tex
+1
-1
Chapter10/Figures/figure-calculation-process-of-context-vector-c.tex
+11
-11
Chapter10/Figures/figure-data-parallel-process.tex
+4
-4
Chapter10/Figures/figure-decode-the-word-probability-distribution-at-the-first-position.tex
+1
-1
Chapter10/Figures/figure-decoding-process-based-on-greedy-method.tex
+2
-2
Chapter10/Figures/figure-double-layer-rnn.tex
+3
-3
Chapter10/Figures/figure-encoder-decoder-with-attention.tex
+14
-14
Chapter10/Figures/figure-model-structure-based-on-recurrent-neural-network-translation.tex
+2
-2
Chapter10/Figures/figure-numbers-of-wmt-systems.tex
+15
-14
Chapter10/Figures/figure-presentation-space.tex
+3
-3
Chapter10/Figures/figure-query-model-corresponding-to-attention-mechanism.tex
+9
-8
Chapter10/Figures/figure-query-model-corresponding-to-traditional-query-model-vs-attention-mechanism.tex
+5
-5
Chapter10/Figures/figure-relationship-between-learning-rate-and-number-of-updates.tex
+1
-1
Chapter10/Figures/figure-score-of-mter.tex
+1
-1
Chapter10/Figures/figure-structure-of-a-recurrent-network-model.tex
+4
-4
Chapter10/Figures/figure-structure-of-gnmt.tex
+10
-10
Chapter11/Figures/figure-average-pooling.tex
+23
-23
Chapter11/Figures/figure-convolution-kernel.tex
+1
-1
Chapter11/Figures/figure-deep-vs-light.tex
+1
-1
Chapter11/Figures/figure-dimension-transformation.tex
+2
-2
Chapter11/Figures/figure-full-connection-vs-cnn-a.tex
+1
-1
Chapter11/Figures/figure-full-connection-vs-cnn-b.tex
+1
-1
Chapter11/Figures/figure-max-pooling.tex
+23
-23
Chapter11/Figures/figure-padding-and-conv.tex
+4
-4
Chapter11/Figures/figure-single-glu.tex
+10
-10
Chapter11/Figures/figure-standard-convolution-neural-network-module.tex
+9
-9
Chapter11/Figures/figure-standard.tex
+2
-2
Chapter11/Figures/figure-use-cnn-in-nmt.tex
+16
-16
Chapter11/Figures/figure-use-cnn-in-sentence-classification.tex
+22
-22
Chapter12/Figures/figure-a-combination-of-position-encoding-and-word-encoding.tex
+16
-16
Chapter12/Figures/figure-calculation-of-context-vector-c.tex
+18
-18
Chapter12/Figures/figure-comparison-of-the-number-of-padding-in-batch.tex
+2
-2
Chapter12/Figures/figure-decode-of-transformer.tex
+9
-9
Chapter12/Figures/figure-dependencies-between-words-in-a-recurrent-neural-network.tex
+5
-5
Chapter12/Figures/figure-dependencies-between-words-of-attention.tex
+5
-5
Chapter12/Figures/figure-different-regularization-methods.tex
+2
-2
Chapter12/Figures/figure-example-of-self-attention-mechanism-calculation.tex
+6
-6
Chapter12/Figures/figure-lrate-of-transformer.tex
+1
-1
Chapter12/Figures/figure-multi-head-attention-model.tex
+17
-15
Chapter12/Figures/figure-point-product-attention-model.tex
+16
-16
Chapter12/Figures/figure-position-of-difference-and-layer-regularization-in-the-model.tex
+4
-4
Chapter12/Figures/figure-position-of-feedforward-neural-network-in-the-model.tex
+5
-5
Chapter12/Figures/figure-position-of-self-attention-mechanism-in-the-model.tex
+3
-3
Chapter12/Figures/figure-process-of-5.tex
+31
-31
Chapter12/Figures/figure-self-att-vs-enco-deco-att.tex
+2
-2
Chapter12/Figures/figure-transformer-input-and-position-encoding.tex
+2
-2
Chapter12/Figures/figure-transformer.tex
+6
-6
没有找到文件。
Chapter10/Figures/figure-3-base-problom-of-p.tex
查看文件 @
89d4bea0
...
...
@@ -12,7 +12,7 @@
% RNN Encoder
\coordinate
(eemb0) at (0,0);
\foreach
\x
[count=
\y
from 0] in
{
1,2,...,3
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
4
\base
]eemb
\y
.east)
{
\tiny
{$
\textrm
{
e
}_
x
()
$}}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
6
\base
]eemb
\y
.east)
{
\tiny
{$
\textrm
{
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
{$
\mathbi
{
h
}_{
m
-
2
}$}}
;
...
...
@@ -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=-
3
em,yshift=0.5em]softmax1.west)
{
\scriptsize
{
基于RNN的隐层状态
$
\mathbi
{
s
}_
i
$}}
;
\node
[anchor=east] (line1) at ([xshift=-
4
em,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|...
)
$}}
;
...
...
@@ -87,7 +87,7 @@
}
{
\node
[anchor=west] (line21) at ([xshift=
1
.3em,yshift=1.5em]enc3.east)
{
\scriptsize
{
源语编码器最后一个
}}
;
\node
[anchor=west] (line21) at ([xshift=
3
.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
{
记为
$
\mathbi
{
C
}$}}
;
...
...
@@ -97,21 +97,21 @@
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=red!10,drop shadow,draw=red,minimum width =9em] [fit = (line1) (line2) (line3) (line4)] (box1)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,very thick,dotted,draw=red] [fit = (softmax1) (softmax2) (softmax3)] (box4)
{}
;
\draw
[->,dotted,very thick,red] ([yshift=1em,xshift=
2
.5em]box1.east) -- ([yshift=1em,xshift=0.1em]box1.east);
\draw
[->,dotted,very thick,red] ([yshift=1em,xshift=
3
.5em]box1.east) -- ([yshift=1em,xshift=0.1em]box1.east);
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!10,drop shadow,draw=ugreen,minimum width =9em] [fit = (line11) (line12) (line13) (line14)] (box2)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (eemb1) (eemb2) (eemb3)] (box5)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (demb1) (demb2) (demb3)] (box6)
{}
;
\draw
[->,dotted,very thick,ugreen] ([yshift=-1.
3em,xshift=2.5em]box2.east) -- ([yshift=-1.3
em,xshift=0.1em]box2.east);
\draw
[->,dotted,very thick,ugreen] ([yshift=-1.
7em,xshift=3.5em]box2.east) -- ([yshift=-1.7
em,xshift=0.1em]box2.east);
\draw
[->,dotted,very thick,ugreen] ([xshift=0.1em]box6.west) .. controls +(west:1) and +(east:1) .. ([yshift=1.0em]box2.east) ;
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=purple!10,drop shadow,draw=purple] [fit = (line21) (line22) (line23) (line24)] (box3)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,very thick,dotted,draw=purple] [fit = (enc3)] (box7)
{}
;
\draw
[->,dotted,very thick,purple] ([xshift=0.1em]box7.east) -- ([xshift=
0
.8em]box7.east) ;
\draw
[->,dotted,very thick,purple] ([xshift=0.1em]box7.east) -- ([xshift=
2
.8em]box7.east) ;
}
\end{pgfonlayer}
...
...
Chapter10/Figures/figure-a-working-example-of-neural-machine-translation.tex
查看文件 @
89d4bea0
...
...
@@ -10,11 +10,11 @@
% RNN Encoder
\coordinate
(eemb0) at (0,0);
\foreach
\x
[count=
\y
from 0] in
{
1,2,...,4
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
4
\base
]eemb
\y
.east)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
7
\base
]eemb
\y
.east)
{}
;
\foreach
\x
in
{
1,2,...,4
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(enc
\x
) at ([yshift=0.5
\base
]eemb
\x
.north)
{}
;
\node
[wordnode,left=0.4\base of enc1,font=\footnotesize]
(init)
{
0
}
;
\node
[wordnode,anchor=east]
(init2) at ([xshift=-3
.0
em]init.west)
{}
;
\node
[wordnode,anchor=east]
(init2) at ([xshift=-3em]init.west)
{}
;
{
\node
[rnnnode,fill=purple]
(repr) at (enc4)
{}
;
\node
[wordnode]
(label) at ([yshift=2.5em]enc4.north)
{
...
...
@@ -35,7 +35,7 @@
% RNN Decoder
\foreach
\x
in
{
1,2,...,4
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=south]
(demb
\x
) at ([xshift=
9
.5em,yshift=-3.9em]enc
\x
.north)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=south]
(demb
\x
) at ([xshift=
12
.5em,yshift=-3.9em]enc
\x
.north)
{}
;
\foreach
\x
in
{
1,2,...,4
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(dec
\x
) at ([yshift=0.5
\base
]demb
\x
.north)
{}
;
\foreach
\x
in
{
1,2,...,4
}
...
...
Chapter10/Figures/figure-attention-of-source-and-target-words.tex
查看文件 @
89d4bea0
...
...
@@ -11,7 +11,7 @@
%\setlength{\mystep}{1.6em}
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(s
\x
) at (
\x
*
1.6
em,0)
{}
;
\node
[]
(s
\x
) at (
\x
*
2
em,0)
{}
;
\node
[] (ws1) at (s1)
{
\scriptsize
{
这
}}
;
\node
[] (ws2) at (s2)
{
\scriptsize
{
是
}}
;
...
...
@@ -21,7 +21,7 @@
\node
[] (ws6) at (s6)
{
\scriptsize
{
句子
}}
;
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(t
\x
) at (
\x
*
1.6em + 2.4
in,0)
{}
;
\node
[]
(t
\x
) at (
\x
*
2em + 2.8
in,0)
{}
;
\node
[] (wt1) at (t1)
{
\scriptsize
{
This
}}
;
\node
[] (wt2) at (t2)
{
\scriptsize
{
is
}}
;
...
...
@@ -30,9 +30,9 @@
\node
[] (wt5) at (t5)
{
\scriptsize
{
long
}}
;
\node
[] (wt6) at ([xshift=1em]t6)
{
\scriptsize
{
sentence
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
6in,minimum height=1.5em] (encoder) at ([yshift=1.0
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=
blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=4.5em]encoder.east)
{
\footnotesize
{
Decoder
}}
;
\node
[anchor=west,fill=
green!30,minimum height=1.5em] (representation) at ([xshift=1em]encoder.east)
{
\footnotesize
{
表示
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
9in,minimum height=1.5em] (encoder) at ([yshift=1.0em,xshift=-0.4
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=
green!30,minimum height=1.5em] (representation) at ([xshift=2em]encoder.east)
{
\footnotesize
{
表示
}}
;
\node
[anchor=west,fill=
blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=2em]representation.east)
{
\footnotesize
{
Decoder
}}
;
\draw
[->,thick] ([xshift=1pt]encoder.east)--([xshift=-1pt]representation.west);
\draw
[->,thick] ([xshift=1pt]representation.east)--([xshift=-1pt]decoder.west);
...
...
Chapter10/Figures/figure-beam-search-process.tex
查看文件 @
89d4bea0
...
...
@@ -5,7 +5,7 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=
3.5
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=
4
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\tikzstyle
{
wnode
}
= [minimum height=1.0em,minimum width=3.5em,inner sep=2pt,rounded corners=1pt,draw,fill=white];
...
...
@@ -137,13 +137,13 @@
}
{
\node
[anchor=east] (vocab) at ([xshift=-
5
em]s1.west)
{
\tiny
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
&
0
.
50
\\
\textrm
{
I
}
&
0
.
02
\\
\textrm
{
it
}
&
0
.
03
\\
\textrm
{
has
}
&
0
.
30
\\
\textrm
{
you
}
&
0
.
01
\\
\textrm
{
the
}
&
0
.
01
\\
\textrm
{
a
}
&
0
.
01
\\
\textrm
{
an
}
&
0
.
02
\\
\textrm
{
he
}
&
0
.
03
\\
\textrm
{
she
}
&
0
.
01
\\
\textrm
{
are
}
&
0
.
00
\\
\textrm
{
am
}
&
0
.
01
\\
...
&
...
\end
{
bmatrix
}$}}
;
\node
[anchor=east] (vocab) at ([xshift=-
8
em]s1.west)
{
\tiny
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
&
0
.
50
\\
\textrm
{
I
}
&
0
.
02
\\
\textrm
{
it
}
&
0
.
03
\\
\textrm
{
has
}
&
0
.
30
\\
\textrm
{
you
}
&
0
.
01
\\
\textrm
{
the
}
&
0
.
01
\\
\textrm
{
a
}
&
0
.
01
\\
\textrm
{
an
}
&
0
.
02
\\
\textrm
{
he
}
&
0
.
03
\\
\textrm
{
she
}
&
0
.
01
\\
\textrm
{
are
}
&
0
.
00
\\
\textrm
{
am
}
&
0
.
01
\\
...
&
...
\end
{
bmatrix
}$}}
;
\node
[anchor=south] (vocablabel) at (vocab.north)
{
\scriptsize
{
单词的概率分布
}}
;
\draw
[->,red,very thick,dotted] (o1.west) .. controls +(west:1) and +(east:2) .. ([yshift=1em]vocab.south east);
}
{
\node
[anchor=east,inner sep=1pt] (vocabtopn) at ([xshift=-
0
.5em,yshift=-0.5em]wo1.west)
{
\scriptsize
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
\\
\textrm
{
has
}
\\
\textrm
{
it
}
\end
{
bmatrix
}$}}
;
\node
[anchor=east,inner sep=1pt] (vocabtopn) at ([xshift=-
1
.5em,yshift=-0.5em]wo1.west)
{
\scriptsize
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
\\
\textrm
{
has
}
\\
\textrm
{
it
}
\end
{
bmatrix
}$}}
;
\draw
[->] ([yshift=-1.6em,xshift=-0.4em]vocab.north east) .. controls +(east:1) and +(west:1) .. ([xshift=0.1em,yshift=0.4em]vocabtopn.west) node [pos=0.3,below] (topnlabel)
{
\scriptsize
{
top-3
}}
;
{
...
...
Chapter10/Figures/figure-bi-rnn.tex
查看文件 @
89d4bea0
...
...
@@ -13,7 +13,7 @@
% RNN Encoder
\coordinate
(eemb0) at (0,0);
\foreach
\x
[count=
\y
from 0] in
{
1,2,...,10
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
4
\base
]eemb
\y
.east)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
7
\base
]eemb
\y
.east)
{}
;
\foreach
\x
in
{
1,2,...,10
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(backenc
\x
) at ([yshift=0.5
\base
]eemb
\x
.north)
{}
;
\foreach
\x
in
{
1,2,...,10
}
...
...
Chapter10/Figures/figure-calculation-process-of-context-vector-c.tex
查看文件 @
89d4bea0
...
...
@@ -8,25 +8,25 @@
\begin{scope}
\node
[anchor=west,draw,fill=red!
2
0!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=1
em]h1.east)
{
\scriptsize
{$
\mathbi
{
h
}_
2
$}}
;
\node
[anchor=west,inner sep=0pt,minimum width=3em] (h3) at ([xshift=
0.5
em]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.5
em]h3.east)
{
\scriptsize
{$
\mathbi
{
h
}_
m
$}}
;
\node
[anchor=west,draw,fill=red!
3
0!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!
30!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h2) at ([xshift=2
em]h1.east)
{
\scriptsize
{$
\mathbi
{
h
}_
2
$}}
;
\node
[anchor=west,inner sep=0pt,minimum width=3em] (h3) at ([xshift=
1
em]h2.east)
{
\scriptsize
{
...
}}
;
\node
[anchor=west,draw,fill=red!
30!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h4) at ([xshift=1
em]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!
2
0!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=2
em]th1.east)
{
\scriptsize
{$
\mathbi
{
s
}_{
j
}$}}
;
\node
[anchor=south,draw,fill=green!
3
0!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!
30!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th2) at ([xshift=2.5
em]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
}$}}
;
\draw
[->] (h4.north) .. controls +(north:0.8) and +(east:1) .. (sum.-10) node [pos=0.1,left] (alphan)
{
\scriptsize
{$
\alpha
_{
m,j
}$}}
;
\draw
[->] ([xshift=-
1.5
em]th1.west) -- ([xshift=-0.1em]th1.west);
\draw
[->] ([xshift=-
2
em]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.5
em]th2.east);
\draw
[->] ([xshift=0.1em]th2.east) -- ([xshift=
2
em]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
{$
\mathbi
{
C
}_{
j
}$}}
;
\node
[anchor=south,inner sep=1pt] (output) at ([yshift=0.8em]th2.north)
{
\scriptsize
{
输出层
}}
;
...
...
@@ -39,7 +39,7 @@
\node
[anchor=north] (enc42) at ([yshift=0.5em]enc4.south)
{
\scriptsize
{
(位置
$
m
$
)
}}
;
{
\node
[anchor=west] (math1) at ([xshift=
5
em,yshift=1em]th2.east)
{$
\mathbi
{
C
}_
j
=
\sum
_{
i
}
\alpha
_{
i,j
}
\mathbi
{
h
}_
i
$
\ \ \ \
}
;
\node
[anchor=west] (math1) at ([xshift=
7
em,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
}
)
}$}
;
...
...
@@ -48,10 +48,10 @@
\begin{pgfonlayer}
{
background
}
{
\node
[rectangle,inner sep=0.4em,rounded corners=1pt,fill=blue!
1
0,drop shadow,minimum width=9.5em] [fit = (math1)] (box1)
{}
;
\node
[rectangle,inner sep=0.4em,rounded corners=1pt,fill=blue!
2
0,drop shadow,minimum width=9.5em] [fit = (math1)] (box1)
{}
;
}
{
\node
[rectangle,inner sep=0.4em,rounded corners=1pt,fill=orange!
1
0,drop shadow,minimum width=9.5em] [fit = (math2) (math3)] (box2)
{}
;
\node
[rectangle,inner sep=0.4em,rounded corners=1pt,fill=orange!
2
0,drop shadow,minimum width=9.5em] [fit = (math2) (math3)] (box2)
{}
;
}
\end{pgfonlayer}
...
...
Chapter10/Figures/figure-data-parallel-process.tex
查看文件 @
89d4bea0
...
...
@@ -17,7 +17,7 @@
\node
[samplenode,anchor=south west,font=
\scriptsize
] (batch
\i
) at ([shift=
{
(-1em,-0.5em)
}
]batch
\j
.south west)
{
句子
\k
}
;
\draw
[decorate,decoration=
{
brace
}
] (batch1.south east) to node [auto,rotate=30,anchor=north,font=
\scriptsize
]
{
batch大小
}
(batch3.south east);
\node
[samplenode,anchor=west,font=
\scriptsize
] (sample2) at ([xshift=
4
em]batch2.east)
{
句子2
}
;
\node
[samplenode,anchor=west,font=
\scriptsize
] (sample2) at ([xshift=
5
em]batch2.east)
{
句子2
}
;
\node
[samplenode,anchor=south,font=
\scriptsize
] (sample3) at ([yshift=3em]sample2.north)
{
句子3
}
;
\node
[samplenode,anchor=north,font=
\scriptsize
] (sample1) at ([yshift=-3em]sample2.south)
{
句子1
}
;
...
...
@@ -26,18 +26,18 @@
\foreach
\i
in
{
1,2,3
}
{
\coordinate
(start) at ([xshift=
2
em]sample
\i
.east);
\coordinate
(start) at ([xshift=
3
em]sample
\i
.east);
\node
[wordnode,anchor=west] (rnn0) at (start)
{$
0
$}
;
\foreach
\j
[count=
\k
from 0] in
{
1,2,3
}
{
\node
[rnnnode,anchor=west] (rnn
\j
) at ([xshift=1em]rnn
\k
.east)
{}
;
\node
[rnnnode,anchor=west] (rnn
\j
) at ([xshift=1
.5
em]rnn
\k
.east)
{}
;
\draw
[-latex'] (rnn
\k
) to (rnn
\j
);
\coordinate
(in
\j
) at ([yshift=-1em]rnn
\j
.south);
\draw
[-latex'] (in
\j
) to (rnn
\j
.south);
\coordinate
(out
\j
) at ([yshift=1em]rnn
\j
.north);
\draw
[-latex'] (rnn
\j
.north) to (out
\j
);
}
\node
[wordnode,anchor=west] (rnn4) at ([xshift=1em]rnn3.east)
{$
\cdots
$}
;
\node
[wordnode,anchor=west] (rnn4) at ([xshift=1
.5
em]rnn3.east)
{$
\cdots
$}
;
\draw
[-latex'] (rnn3) to (rnn4);
\node
[draw,densely dashed,thick,rounded corners=0.3em,fit=(start) (in3) (out3) (rnn4),label=
{
[font=
\footnotesize
,rotate=90,anchor=north]0:设备
\i
}
] (rnn)
{}
;
\draw
[->,double] ([xshift=3pt]sample
\i
.east) -- ([xshift=-3pt]rnn.west);
...
...
Chapter10/Figures/figure-decode-the-word-probability-distribution-at-the-first-position.tex
查看文件 @
89d4bea0
...
...
@@ -42,7 +42,7 @@
}
{
\node
[anchor=east] (vocab) at ([xshift=-
5
em]s1.west)
{
\tiny
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
&
0
.
50
\\
\textrm
{
I
}
&
0
.
02
\\
\textrm
{
it
}
&
0
.
03
\\
\textrm
{
has
}
&
0
.
30
\\
\textrm
{
you
}
&
0
.
01
\\
\textrm
{
the
}
&
0
.
01
\\
\textrm
{
a
}
&
0
.
01
\\
\textrm
{
an
}
&
0
.
02
\\
\textrm
{
he
}
&
0
.
03
\\
\textrm
{
she
}
&
0
.
01
\\
\textrm
{
are
}
&
0
.
00
\\
\textrm
{
am
}
&
0
.
01
\\
...
&
...
\end
{
bmatrix
}$}}
;
\node
[anchor=east] (vocab) at ([xshift=-
7
em]s1.west)
{
\tiny
{$
\begin
{
bmatrix
}
\textrm
{
Have
}
&
0
.
50
\\
\textrm
{
I
}
&
0
.
02
\\
\textrm
{
it
}
&
0
.
03
\\
\textrm
{
has
}
&
0
.
30
\\
\textrm
{
you
}
&
0
.
01
\\
\textrm
{
the
}
&
0
.
01
\\
\textrm
{
a
}
&
0
.
01
\\
\textrm
{
an
}
&
0
.
02
\\
\textrm
{
he
}
&
0
.
03
\\
\textrm
{
she
}
&
0
.
01
\\
\textrm
{
are
}
&
0
.
00
\\
\textrm
{
am
}
&
0
.
01
\\
...
&
...
\end
{
bmatrix
}$}}
;
\node
[anchor=south] (vocablabel) at (vocab.north)
{
\scriptsize
{
单词的概率分布
}}
;
\draw
[->,red,very thick,dotted] (o1.west) .. controls +(west:1) and +(east:2) .. ([yshift=1em]vocab.south east);
}
...
...
Chapter10/Figures/figure-decoding-process-based-on-greedy-method.tex
查看文件 @
89d4bea0
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.
1
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.
7
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\node
[rnnnode,anchor=west] (h1) at (0,0)
{
\tiny
{$
\mathbi
{
h
}_
1
$}}
;
\node
[anchor=west] (h2) at ([xshift=1em]h1.east)
{
\tiny
{
...
}}
;
...
...
@@ -139,7 +139,7 @@
\draw
[->] ([yshift=-0.3em]s1.west) .. controls +(west:2) and +(-50:0.3) .. (c2.-40);
}
{
\draw
[->] (c2.0) -- ([xshift=1.
2in]c2.0) -- ([yshift=0.3em,xshift=-1.2
em]s2.west) -- ([yshift=0.3em,xshift=-0.1em]s2.west);
\draw
[->] (c2.0) -- ([xshift=1.
4in]c2.0) -- ([yshift=0.3em,xshift=-1
em]s2.west) -- ([yshift=0.3em,xshift=-0.1em]s2.west);
}
{
...
...
Chapter10/Figures/figure-double-layer-rnn.tex
查看文件 @
89d4bea0
...
...
@@ -10,7 +10,7 @@
% RNN Encoder
\coordinate
(eemb0) at (0,0);
\foreach
\x
[count=
\y
from 0] in
{
1,2,...,10
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
4
\base
]eemb
\y
.east)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
7
\base
]eemb
\y
.east)
{}
;
\foreach
\x
in
{
1,2,...,10
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(enc1
\x
) at ([yshift=0.3
\base
]eemb
\x
.north)
{}
;
\foreach
\x
in
{
1,2,...,10
}
...
...
@@ -121,10 +121,10 @@
}
\coordinate
(bridge) at ([yshift=1.4
\base
]enc16.north west);
\draw
[-latex']
(enc210.north) .. controls +(north:0.
4
\base
) and +(east:1.5
\base
) .. (bridge) .. controls +(west:8.0
\base
) and +(south west:0
.8
\base
) .. (dec21.west);
\draw
[-latex']
(enc210.north) .. controls +(north:0.
6
\base
) and +(east:2
\base
) .. (bridge) .. controls +(west:8.0
\base
) and +(south west:2
.8
\base
) .. (dec21.west);
\coordinate
(bridge) at ([yshift=1.6
\base
]enc16.north west);
\draw
[-latex']
(
enc110.east) .. controls +(east:0.5
\base
) and +(east:8
\base
) .. (bridge) .. controls +(west:7.5
\base
) and +(south west:0.1
\base
) .. (dec11.west);
\draw
[-latex']
(
[yshift=-0.5em]enc110.east) .. controls +(north:1.5
\base
) and +(east:8
\base
) .. (bridge) .. controls +(west:7.5
\base
) and +(south west:1.2
\base
) .. (dec11.west);
% stack RNN
\begin{pgfonlayer}
{
background
}
...
...
Chapter10/Figures/figure-encoder-decoder-with-attention.tex
查看文件 @
89d4bea0
...
...
@@ -11,7 +11,7 @@
%%% a simple encoder-decoder model
\begin{scope}
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(s
\x
) at (
\x
*
1.6
em,0)
{}
;
\node
[]
(s
\x
) at (
\x
*
2
em,0)
{}
;
\node
[] (ws1) at (s1)
{
\scriptsize
{
这
}}
;
\node
[] (ws2) at (s2)
{
\scriptsize
{
是
}}
;
...
...
@@ -21,7 +21,7 @@
\node
[] (ws6) at (s6)
{
\scriptsize
{
句子
}}
;
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(t
\x
) at (
\x
*
1.6em + 2.4
in,0)
{}
;
\node
[]
(t
\x
) at (
\x
*
2em + 2.8
in,0)
{}
;
\node
[] (wt1) at (t1)
{
\scriptsize
{
This
}}
;
\node
[] (wt2) at (t2)
{
\scriptsize
{
is
}}
;
...
...
@@ -30,9 +30,9 @@
\node
[] (wt5) at (t5)
{
\scriptsize
{
long
}}
;
\node
[] (wt6) at ([xshift=1em]t6)
{
\scriptsize
{
sentence
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
6in,minimum height=1.5em] (encoder) at ([yshift=1.0
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=
blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=4.5em]encoder.east)
{
\footnotesize
{
Decoder
}}
;
\node
[anchor=west,fill=
green!30,minimum height=1.5em] (representation) at ([xshift=1em]encoder.east)
{
\footnotesize
{
表示
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
9in,minimum height=1.5em] (encoder) at ([yshift=1.0em,xshift=-0.4
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=
green!30,minimum height=1.5em] (representation) at ([xshift=2em]encoder.east)
{
\footnotesize
{
表示
}}
;
\node
[anchor=west,fill=
blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=2em]representation.east)
{
\footnotesize
{
Decoder
}}
;
\draw
[->,thick] ([xshift=1pt]encoder.east)--([xshift=-1pt]representation.west);
\draw
[->,thick] ([xshift=1pt]representation.east)--([xshift=-1pt]decoder.west);
...
...
@@ -42,7 +42,7 @@
\foreach
\x
in
{
1,2,...,5
}
\draw
[<-]
([yshift=0.1em]t
\x
.north) -- ([yshift=1.2em]t
\x
.north);
\draw
[<-]
([yshift=0.1em,xshift=1em]t6.north) -- ([yshift=1.2em,xshift=1em]t6.north);
\draw
[<-
,thick
]
([yshift=0.1em,xshift=1em]t6.north) -- ([yshift=1.2em,xshift=1em]t6.north);
\node
[anchor=north] (cap) at ([xshift=2em,yshift=-2.5em]encoder.south east)
{
\small
{
(a) 简单的编码器-解码器框架
}}
;
\end{scope}
...
...
@@ -50,7 +50,7 @@
%%% a encoder-decoder model with attention
\begin{scope}
[yshift=-1.7in]
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(s
\x
) at (
\x
*
1.6
em,0)
{}
;
\node
[]
(s
\x
) at (
\x
*
2
em,0)
{}
;
\node
[] (ws1) at (s1)
{
\scriptsize
{
这
}}
;
\node
[] (ws2) at (s2)
{
\scriptsize
{
是
}}
;
...
...
@@ -60,7 +60,7 @@
\node
[] (ws6) at (s6)
{
\scriptsize
{
句子
}}
;
\foreach
\x
in
{
1,2,...,6
}
\node
[]
(t
\x
) at (
\x
*
1.6em + 2.4
in,0)
{}
;
\node
[]
(t
\x
) at (
\x
*
2em + 2.8
in,0)
{}
;
\node
[] (wt1) at (t1)
{
\scriptsize
{
This
}}
;
\node
[] (wt2) at (t2)
{
\scriptsize
{
is
}}
;
...
...
@@ -69,8 +69,8 @@
\node
[] (wt5) at (t5)
{
\scriptsize
{
long
}}
;
\node
[] (wt6) at ([xshift=1em]t6)
{
\scriptsize
{
sentence
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
6in,minimum height=1.5em] (encoder) at ([yshift=1.0
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=
4.5
em]encoder.east)
{
\footnotesize
{
Decoder
}}
;
\node
[anchor=south west,fill=red!30,minimum width=1.
9in,minimum height=1.5em] (encoder) at ([yshift=1.0em,xshift=-0.4
em]ws1.north west)
{
\footnotesize
{
Encoder
}}
;
\node
[anchor=west,fill=blue!30,minimum width=1.9in,minimum height=1.5em] (decoder) at ([xshift=
6.4
em]encoder.east)
{
\footnotesize
{
Decoder
}}
;
\foreach
\x
in
{
1,2,...,6
}
\draw
[->]
([yshift=0.1em]s
\x
.north) -- ([yshift=1.2em]s
\x
.north);
...
...
@@ -78,11 +78,11 @@
\foreach
\x
in
{
1,2,...,5
}
\draw
[<-]
([yshift=0.1em]t
\x
.north) -- ([yshift=1.2em]t
\x
.north);
\draw
[<-]
([yshift=0.1em,xshift=1em]t6.north) -- ([yshift=1.2em,xshift=1em]t6.north);
\draw
[<-
,thick
]
([yshift=0.1em,xshift=1em]t6.north) -- ([yshift=1.2em,xshift=1em]t6.north);
\draw
[->] ([yshift=3em]s6.north) -- ([yshift=4em]s6.north) -- ([yshift=4em]t1.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c1)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
1
$}}
-- ([yshift=3em]t1.north) ;
\draw
[->] ([yshift=3em]s5.north) -- ([yshift=5.3em]s5.north) -- ([yshift=5.3em]t2.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c2)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
2
$}}
-- ([yshift=3em]t2.north) ;
\draw
[->] ([yshift=3.5em]s3.north) -- ([yshift=6.6em]s3.north) -- ([yshift=6.6em]t4.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c3)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
i
$}}
-- ([yshift=3.5em]t4.north) ;
\draw
[->
,thick
] ([yshift=3em]s6.north) -- ([yshift=4em]s6.north) -- ([yshift=4em]t1.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c1)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
1
$}}
-- ([yshift=3em]t1.north) ;
\draw
[->
,thick
] ([yshift=3em]s5.north) -- ([yshift=5.3em]s5.north) -- ([yshift=5.3em]t2.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c2)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
2
$}}
-- ([yshift=3em]t2.north) ;
\draw
[->
,thick
] ([yshift=3.5em]s3.north) -- ([yshift=6.6em]s3.north) -- ([yshift=6.6em]t4.north) node [pos=0.5,fill=green!30,inner sep=2pt] (c3)
{
\scriptsize
{
表示
$
\mathbi
{
C
}_
i
$}}
-- ([yshift=3.5em]t4.north) ;
\node
[anchor=north] (smore) at ([yshift=3.5em]s3.north)
{
...
}
;
\node
[anchor=north] (tmore) at ([yshift=3.5em]t4.north)
{
...
}
;
...
...
Chapter10/Figures/figure-model-structure-based-on-recurrent-neural-network-translation.tex
查看文件 @
89d4bea0
...
...
@@ -11,7 +11,7 @@
% RNN Encoder
\coordinate
(eemb0) at (0,0);
\foreach
\x
[count=
\y
from 0] in
{
1,2,...,10
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
4
\base
]eemb
\y
.east)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.
7
\base
]eemb
\y
.east)
{}
;
\foreach
\x
in
{
1,2,...,10
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(enc
\x
) at ([yshift=0.5
\base
]eemb
\x
.north)
{}
;
\node
[wordnode,left=0.4\base of enc1]
(init)
{$
0
$}
;
...
...
@@ -114,7 +114,7 @@
% legend
\begin{scope}
[shift=
{
(10
\base
,2.5
\base
)
}
]
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,label={[label distance=3pt,font=\scriptsize]
0:词嵌入层
}
] (emb) at (
0
,0)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,label={[label distance=3pt,font=\scriptsize]
0:词嵌入层
}
] (emb) at (
3
,0)
{}
;
\node
[rnnnode,fill=blue!30!white,anchor=north west,label={[label distance=3pt,font=\scriptsize]
0:循环单元
}
] (rnn) at ([yshift=2
\base
]emb.south west)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=north west,label={[label distance=3pt,font=\scriptsize]
0:输出层
}
] (softmax) at ([yshift=2
\base
]rnn.south west)
{}
;
\node
[anchor=north west] (softmax2) at ([xshift=0.6
\base
]softmax.south west)
{
\scriptsize
{
Softmax
}}
;
...
...
Chapter10/Figures/figure-numbers-of-wmt-systems.tex
查看文件 @
89d4bea0
...
...
@@ -5,7 +5,7 @@
\begin{tikzpicture}
\begin{scope}
[local bounding box=WMT]
\draw
[->,thick]
(0.4,0) to (
9
.5,0);
\draw
[->,thick]
(0.4,0) to (
11
.5,0);
\draw
[->,thick]
(0.4,-0) to (0.4,4.3);
\draw
[thick]
(0.4,2) to (0.6,2);
\draw
[thick]
(0.4,4) to (0.6,4);
...
...
@@ -13,38 +13,38 @@
\node
[font=\scriptsize]
at (0,4)
{
20
}
;
% 2015
\node
[minimum width=0.
5
cm,thick,minimum height=7*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2015) at (1.5*0.7,0.5pt)
{}
;
\node
[minimum width=0.
5
cm,thick,minimum height=2*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2015) at (smt2015.south east)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=7*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2015) at (1.5*0.7,0.5pt)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=2*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2015) at (smt2015.south east)
{}
;
\node
[font=\scriptsize,anchor=north]
() at ([yshift=-0.2em]smt2015.south east)
{
2015
}
;
% 2016
\node
[minimum width=0.
5
cm,thick,minimum height=3*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2016) at (
$
(
nmt
2015
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
5
cm,thick,minimum height=8*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2016) at (smt2016.south east)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=3*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2016) at (
$
(
nmt
2015
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=8*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2016) at (smt2016.south east)
{}
;
\node
[font=\scriptsize,anchor=north]
() at ([yshift=-0.2em]smt2016.south east)
{
2016
}
;
% 2017
\node
[minimum width=0.
5
cm,thick,minimum height=3*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2017) at (
$
(
nmt
2016
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
5
cm,thick,minimum height=13*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2017) at (smt2017.south east)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=3*0.2cm,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2017) at (
$
(
nmt
2016
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=13*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2017) at (smt2017.south east)
{}
;
\node
[font=\scriptsize,anchor=north]
() at ([yshift=-0.2em]smt2017.south east)
{
2017
}
;
% 2018
\node
[minimum width=0.
5
cm,thick,minimum height=0cm,draw,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2018) at (
$
(
nmt
2017
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
5
cm,thick,minimum height=14*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2018) at (smt2018.south east)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=0cm,draw,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2018) at (
$
(
nmt
2017
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=14*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2018) at (smt2018.south east)
{}
;
\node
[font=\scriptsize,anchor=north]
() at ([yshift=-0.2em]smt2018.south east)
{
2018
}
;
% 2019
\node
[minimum width=0.
5
cm,thick,minimum height=0cm,draw,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2019) at (
$
(
nmt
2018
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
5
cm,thick,minimum height=21*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2019) at (smt2019.south east)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=0cm,draw,fill=blue!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(smt2019) at (
$
(
nmt
2018
.south east
)+(
0
.
7
,
0
)
$
)
{}
;
\node
[minimum width=0.
7
cm,thick,minimum height=21*0.2cm,fill=red!30!white,inner sep=0pt,outer sep=0pt,anchor=south west]
(nmt2019) at (smt2019.south east)
{}
;
\node
[font=\scriptsize,anchor=north]
() at ([yshift=-0.2em]smt2019.south east)
{
2019
}
;
\end{scope}
% legend
\ExtractX
{$
(
nmt
2015
.west
)
$}
\ExtractY
{$
(
WMT.north
)
$}
\node
[minimum width=0.
5
cm,rectangle,fill=blue!30!white,anchor=north west,label={[label distance=1pt,font=\scriptsize]
0:统计机器翻译
}
] () at (
\XCoord
,
\YCoord
)
{}
;
\node
[minimum width=0.
7
cm,rectangle,fill=blue!30!white,anchor=north west,label={[label distance=1pt,font=\scriptsize]
0:统计机器翻译
}
] () at (
\XCoord
,
\YCoord
)
{}
;
\ExtractX
{$
(
nmt
2017
.west
)
$}
\node
[minimum width=0.
5
cm,rectangle,fill=red!30!white,anchor=north west,label={[label distance=1pt,font=\scriptsize]
0:神经机器翻译
}
] () at (
\XCoord
,
\YCoord
)
{}
;
\node
[minimum width=0.
7
cm,rectangle,fill=red!30!white,anchor=north west,label={[label distance=1pt,font=\scriptsize]
0:神经机器翻译
}
] () at (
\XCoord
,
\YCoord
)
{}
;
% \node[font=\normalsize,rotate=90] () at ([xshift=-1em]WMT.west) {数量};
\node
[font=\normalsize]
() at (0.4,4.5)
{
数量
}
;
\node
[font=\normalsize]
() at (
9
.5,-0.3)
{
年份
}
;
\node
[font=\normalsize]
() at (
11
.5,-0.3)
{
年份
}
;
\end{tikzpicture}
\ No newline at end of file
Chapter10/Figures/figure-presentation-space.tex
查看文件 @
89d4bea0
...
...
@@ -19,13 +19,13 @@
\end{scope}
\begin{scope}
[xshift=1.
3
in]
\begin{scope}
[xshift=1.
8
in]
\node
[anchor=south west,draw,thick,red,minimum width=0.9in,minimum height=0.7in] (space1) at (0,0)
{}
;
\node
[anchor=south west,fill=blue,minimum width=0.1in,minimum height=0.1in] (unit1) at (0.2,0.8)
{}
;
\node
[anchor=south west,fill=ugreen,minimum width=0.1in,minimum height=0.1in] (unit2) at (0.7,0.3)
{}
;
\node
[anchor=south west,draw,thick,red,minimum width=0.9in,minimum height=0.7in] (space2) at (1.
1
in,0)
{}
;
\node
[anchor=south west,circle,fill=orange,minimum width=0.1in,minimum height=0.1in] (unit3) at (1.
5
in,1.3)
{}
;
\node
[anchor=south west,draw,thick,red,minimum width=0.9in,minimum height=0.7in] (space2) at (1.
3
in,0)
{}
;
\node
[anchor=south west,circle,fill=orange,minimum width=0.1in,minimum height=0.1in] (unit3) at (1.
7
in,1.3)
{}
;
\draw
[->] ([yshift=1pt]unit1.north) .. controls +(north:0.4) and +(west:2) .. ([yshift=0.0em,xshift=-1pt]unit3.west);
\draw
[->] ([xshift=1pt]unit2.east) .. controls +(east:1.5) and +(south:1) .. ([xshift=0.0em,yshift=-1pt]unit3.south);
...
...
Chapter10/Figures/figure-query-model-corresponding-to-attention-mechanism.tex
查看文件 @
89d4bea0
...
...
@@ -5,26 +5,26 @@
\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
{${
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=
1
em]value1.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=
1
em]value2.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=
1
em]value3.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=
2
em]value1.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=
2
em]value2.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=
2
em]value3.south east)
{
\scriptsize
{${
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key1) at ([yshift=0.2em]value1.north west)
{
\scriptsize
{${
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key2) at ([yshift=0.2em]value2.north west)
{
\scriptsize
{${
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key3) at ([yshift=0.2em]value3.north west)
{
\scriptsize
{${
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key4) at ([yshift=0.2em]value4.north west)
{
\scriptsize
{${
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=east] (query) at ([xshift=-
2
em]key1.west)
{
\scriptsize
{${
s
}
(
\textrm
{
you
}
)
$}}
;
\node
[rnode,anchor=east] (query) at ([xshift=-
4
em]key1.west)
{
\scriptsize
{${
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);
\draw
[->] ([yshift=1pt,xshift=3pt]query.north) .. controls +(90:1.5em) and +(90:1.5em) .. ([yshift=1pt]key2.north);
\draw
[->] ([yshift=1pt]query.north) .. controls +(90:2em) and +(90:2em) .. ([yshift=1pt]key3.north);
\draw
[->] ([yshift=1pt,xshift=-3pt]query.north) .. controls +(90:2.5em) and +(90:2.5em) .. ([yshift=1pt]key4.north);
\node
[anchor=south east] (alpha1) at ([xshift=1
em]key1.north east)
{
\scriptsize
{$
\alpha
_
1
=
.
4
$}}
;
\node
[anchor=south east] (alpha2) at ([xshift=1
em]key2.north east)
{
\scriptsize
{$
\alpha
_
2
=
.
4
$}}
;
\node
[anchor=south east] (alpha3) at ([xshift=1
em]key3.north east)
{
\scriptsize
{$
\alpha
_
3
=
.
1
$}}
;
\node
[anchor=south east] (alpha4) at ([xshift=1
em]key4.north east)
{
\scriptsize
{$
\alpha
_
4
=
.
1
$}}
;
\node
[anchor=south east] (alpha1) at ([xshift=1
.5em]key1.north east)
{
\scriptsize
{$
\alpha
_
1
=
0
.
4
$}}
;
\node
[anchor=south east] (alpha2) at ([xshift=1
.5em]key2.north east)
{
\scriptsize
{$
\alpha
_
2
=
0
.
4
$}}
;
\node
[anchor=south east] (alpha3) at ([xshift=1
.5em]key3.north east)
{
\scriptsize
{$
\alpha
_
3
=
0
.
1
$}}
;
\node
[anchor=south east] (alpha4) at ([xshift=1
.5em]key4.north east)
{
\scriptsize
{$
\alpha
_
4
=
0
.
1
$}}
;
\end{scope}
\end{tikzpicture}
\ No newline at end of file
Chapter10/Figures/figure-query-model-corresponding-to-traditional-query-model-vs-attention-mechanism.tex
查看文件 @
89d4bea0
...
...
@@ -5,12 +5,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnode
}
= [draw,minimum width=3em,minimum height=1.2em]
\tikzstyle
{
rnode
}
= [draw,minimum width=3
.5
em,minimum height=1.2em]
\node
[rnode,anchor=south west,fill=blue!20!white] (value1) at (0,0)
{
\scriptsize
{
value
$_
1
$}}
;
\node
[rnode,anchor=south west,fill=blue!20!white] (value2) at ([xshift=
1
em]value1.south east)
{
\scriptsize
{
value
$_
2
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=
1
em]value2.south east)
{
\scriptsize
{
value
$_
3
$}}
;
\node
[rnode,anchor=south west,fill=blue!20!white] (value4) at ([xshift=
1
em]value3.south east)
{
\scriptsize
{
value
$_
4
$}}
;
\node
[rnode,anchor=south west,fill=blue!20!white] (value2) at ([xshift=
2
em]value1.south east)
{
\scriptsize
{
value
$_
2
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=
2
em]value2.south east)
{
\scriptsize
{
value
$_
3
$}}
;
\node
[rnode,anchor=south west,fill=blue!20!white] (value4) at ([xshift=
2
em]value3.south east)
{
\scriptsize
{
value
$_
4
$}}
;
\node
[rnode,anchor=south west,pattern=north east lines] (key1) at ([yshift=0.2em]value1.north west)
{}
;
\node
[rnode,anchor=south west,pattern=dots] (key2) at ([yshift=0.2em]value2.north west)
{}
;
...
...
@@ -21,7 +21,7 @@
\node
[fill=white,inner sep=1pt] (key1label) at (key3)
{
\scriptsize
{
key
$_
3
$}}
;
\node
[fill=white,inner sep=1pt] (key1label) at (key4)
{
\scriptsize
{
key
$_
4
$}}
;
\node
[rnode,anchor=east,pattern=horizontal lines] (query) at ([xshift=-
3
em]key1.west)
{}
;
\node
[rnode,anchor=east,pattern=horizontal lines] (query) at ([xshift=-
4
em]key1.west)
{}
;
\node
[anchor=east] (querylabel) at ([xshift=-0.2em]query.west)
{
\scriptsize
{
query
}}
;
\draw
[->] ([yshift=1pt]query.north) .. controls +(90:2em) and +(90:2em) .. ([yshift=1pt]key3.north) node [pos=0.5,below,yshift=0.2em]
{
\scriptsize
{
匹配
}}
;
...
...
Chapter10/Figures/figure-relationship-between-learning-rate-and-number-of-updates.tex
查看文件 @
89d4bea0
...
...
@@ -4,7 +4,7 @@
\begin{tikzpicture}
\footnotesize
{
\begin{axis}
[
width=.
60
\textwidth
,
width=.
8
\textwidth
,
height=.40
\textwidth
,
legend style=
{
at=
{
(0.60,0.08)
}
, anchor=south west
}
,
xlabel=
{
\scriptsize
{
更新次数
}}
,
...
...
Chapter10/Figures/figure-score-of-mter.tex
查看文件 @
89d4bea0
...
...
@@ -2,7 +2,7 @@
%\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\begin{tikzpicture}
\begin{axis}
[
width=1
0
cm, height=5cm,
width=1
2
cm, height=5cm,
symbolic x coords=
{
1-15,16-25,26-35,>35
}
,
xtick=data,
ytick=
{
6,12,...,28
}
,
...
...
Chapter10/Figures/figure-structure-of-a-recurrent-network-model.tex
查看文件 @
89d4bea0
...
...
@@ -6,11 +6,11 @@
\begin{scope}
[scale=0.9]
{
\Large
\tikzstyle
{
rnnnode
}
= [draw,inner sep=5pt,minimum width=3em,minimum height=0.8em,fill=green!30!white,blur shadow=
{
shadow xshift=1pt,shadow yshift=-1pt
}
]
\tikzstyle
{
rnnnode
}
= [draw,inner sep=5pt,minimum width=3
.6
em,minimum height=0.8em,fill=green!30!white,blur shadow=
{
shadow xshift=1pt,shadow yshift=-1pt
}
]
\node
[anchor=west,rnnnode] (node11) at (0,0)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node12) at ([xshift=
1
em]node11.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node13) at ([xshift=
1
em]node12.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node14) at ([xshift=
1
em]node13.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node12) at ([xshift=
2
em]node11.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node13) at ([xshift=
2
em]node12.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=west,rnnnode] (node14) at ([xshift=
2
em]node13.east)
{
\scriptsize
{
RNN Cell
}}
;
\node
[anchor=north,rnnnode,fill=blue!30!white] (e1) at ([yshift=-1em]node11.south)
{
\scriptsize
{}}
;
\node
[anchor=north,rnnnode,fill=blue!30!white] (e2) at ([yshift=-1em]node12.south)
{
\scriptsize
{}}
;
...
...
Chapter10/Figures/figure-structure-of-gnmt.tex
查看文件 @
89d4bea0
...
...
@@ -12,9 +12,9 @@
% Encoder
\begin{scope}
\node
[rnnnode,fill=green!20]
(encemb1) at (0,0)
{}
;
\node
[rnnnode,fill=green!20,right=\base of encemb1]
(encemb2)
{}
;
\node
[rnnnode,draw=white,fill=white,right=\base of encemb2]
(encemb3)
{$
\cdots
$}
;
\node
[rnnnode,fill=green!20,right=\base of encemb3]
(encemb4)
{}
;
\node
[rnnnode,fill=green!20,right=
1.8
\base of encemb1]
(encemb2)
{}
;
\node
[rnnnode,draw=white,fill=white,right=
1.8
\base of encemb2]
(encemb3)
{$
\cdots
$}
;
\node
[rnnnode,fill=green!20,right=
1.8
\base of encemb3]
(encemb4)
{}
;
\node
[rnnnode,above=\base of encemb1]
(enc11)
{}
;
\node
[rnnnode,above=\base of encemb2]
(enc12)
{}
;
...
...
@@ -103,10 +103,10 @@
\node
[rnnnode,fill=orange!20,minimum width=3.5cm,anchor=south west]
(attention) at ([yshift=
\base
]enc61.north west)
{
注意力机制
}
;
\begin{scope}
\node
[rnnnode,fill=green!20,right=
2.5
cm of encemb4]
(decemb1)
{}
;
\node
[rnnnode,fill=green!20,right=\base of decemb1]
(decemb2)
{}
;
\node
[rnnnode,draw=white,fill=white,right=\base of decemb2]
(decemb3)
{$
\cdots
$}
;
\node
[rnnnode,fill=green!20,right=\base of decemb3]
(decemb4)
{}
;
\node
[rnnnode,fill=green!20,right=
3
cm of encemb4]
(decemb1)
{}
;
\node
[rnnnode,fill=green!20,right=
1.8
\base of decemb1]
(decemb2)
{}
;
\node
[rnnnode,draw=white,fill=white,right=
1.8
\base of decemb2]
(decemb3)
{$
\cdots
$}
;
\node
[rnnnode,fill=green!20,right=
1.8
\base of decemb3]
(decemb4)
{}
;
\node
[rnnnode,above=\base of decemb1]
(dec11)
{}
;
\node
[rnnnode,above=\base of decemb2]
(dec12)
{}
;
...
...
@@ -189,7 +189,7 @@
\end{scope}
% attention connections
\draw
[-latex',rounded corners=2pt]
(dec11) -| ([xshift=-0.
4
cm]attention.south east);
\draw
[-latex',rounded corners=2pt]
(dec11) -| ([xshift=-0.
2
cm]attention.south east);
\ExtractX
{$
([
xshift
=
9
pt
]
attention.east
)
$}
\ExtractY
{$
([
yshift
=
2
pt
]
dec
11
.north
)
$}
...
...
@@ -224,11 +224,11 @@
\draw
[decorate,decoration={brace,mirror}]
([xshift=5pt]dec14.south east) to node [auto,swap,font=
\scriptsize
,name=label2]
{
8层
}
([xshift=5pt]dec54.north east);
\begin{pgfonlayer}
{
background
}
\coordinate
(tmp) at ([xshift=-4pt]label1.west);
\node
[draw,densely dashed,rounded corners=2pt,inner sep=2pt,fit=(label1) (encword1) (attention) (tmp)]
(encoder)
{}
;
\node
[
thick,
draw,densely dashed,rounded corners=2pt,inner sep=2pt,fit=(label1) (encword1) (attention) (tmp)]
(encoder)
{}
;
\ExtractX
{$
([
xshift
=
4
pt
]
label
2
.east
)
$}
\ExtractY
{$
([
yshift
=
6
pt
]
decoutword
4
.north
)
$}
\coordinate
(tmp) at (
\XCoord
,
\YCoord
);
\node
[draw,densely dashed,rounded corners=2pt,inner sep=2pt,fit=(label2) (decinword1) (decoutword4) (tmp)]
(decoder)
{}
;
\node
[
thick,
draw,densely dashed,rounded corners=2pt,inner sep=2pt,fit=(label2) (decinword1) (decoutword4) (tmp)]
(decoder)
{}
;
\end{pgfonlayer}
\node
[wnode,anchor=north west]
() at (encoder.north west)
{
编码器
}
;
\node
[wnode,anchor=north east]
() at (decoder.north east)
{
解码器
}
;
...
...
Chapter11/Figures/figure-average-pooling.tex
查看文件 @
89d4bea0
...
...
@@ -2,32 +2,32 @@
\begin{tikzpicture}
[node distance = 0cm]
\node
(num1)[num,fill=red!
1
0]
{
1
}
;
\node
(num2)[num,below of = num1,yshift= -0.6cm,fill=red!
1
0]
{
5
}
;
\node
(num3)[num,right of = num1,xshift= 0.6cm,fill=red!
1
0]
{
0
}
;
\node
(num4)[num,below of = num3,yshift= -0.6cm,fill=red!
1
0]
{
6
}
;
\node
(num5)[num,right of = num3,xshift= 0.6cm,fill=green!
1
0]
{
4
}
;
\node
(num6)[num,below of = num5,yshift= -0.6cm,fill=green!
1
0]
{
7
}
;
\node
(num7)[num,right of = num5,xshift= 0.6cm,fill=green!
1
0]
{
5
}
;
\node
(num8)[num,below of = num7,yshift= -0.6cm,fill=green!
1
0]
{
8
}
;
\node
(num9)[num,below of = num2,yshift= -0.6cm,fill=yellow!
1
0]
{
3
}
;
\node
(num
10)[num,below of = num9,yshift= -0.6cm,fill=yellow!1
0]
{
1
}
;
\node
(num11)[num,right of = num9,xshift= 0.6cm,fill=yellow!
1
0]
{
2
}
;
\node
(num12)[num,below of = num11,yshift= -0.6cm,fill=yellow!
1
0]
{
2
}
;
\node
(num13)[num,right of = num11,xshift= 0.6cm,fill=blue!
1
0]
{
1
}
;
\node
(num14)[num,below of = num13,yshift= -0.6cm,fill=blue!
1
0]
{
3
}
;
\node
(num
10)[num,right of = num13,xshift= 0.6cm,fill=blue!1
0]
{
0
}
;
\node
(num16)[num,below of = num
10,yshift= -0.6cm,fill=blue!1
0]
{
4
}
;
\node
(num1)[num,fill=red!
2
0]
{
1
}
;
\node
(num2)[num,below of = num1,yshift= -0.6cm,fill=red!
2
0]
{
5
}
;
\node
(num3)[num,right of = num1,xshift= 0.6cm,fill=red!
2
0]
{
0
}
;
\node
(num4)[num,below of = num3,yshift= -0.6cm,fill=red!
2
0]
{
6
}
;
\node
(num5)[num,right of = num3,xshift= 0.6cm,fill=green!
2
0]
{
4
}
;
\node
(num6)[num,below of = num5,yshift= -0.6cm,fill=green!
2
0]
{
7
}
;
\node
(num7)[num,right of = num5,xshift= 0.6cm,fill=green!
2
0]
{
5
}
;
\node
(num8)[num,below of = num7,yshift= -0.6cm,fill=green!
2
0]
{
8
}
;
\node
(num9)[num,below of = num2,yshift= -0.6cm,fill=yellow!
2
0]
{
3
}
;
\node
(num
20)[num,below of = num9,yshift= -0.6cm,fill=yellow!2
0]
{
1
}
;
\node
(num11)[num,right of = num9,xshift= 0.6cm,fill=yellow!
2
0]
{
2
}
;
\node
(num12)[num,below of = num11,yshift= -0.6cm,fill=yellow!
2
0]
{
2
}
;
\node
(num13)[num,right of = num11,xshift= 0.6cm,fill=blue!
2
0]
{
1
}
;
\node
(num14)[num,below of = num13,yshift= -0.6cm,fill=blue!
2
0]
{
3
}
;
\node
(num
20)[num,right of = num13,xshift= 0.6cm,fill=blue!2
0]
{
0
}
;
\node
(num16)[num,below of = num
20,yshift= -0.6cm,fill=blue!2
0]
{
4
}
;
\draw
[->,thick]
([xshift=0.4cm,yshift=-0.4cm]num8.east)--([xshift=1.5cm,yshift=-0.4cm]num8.east);
\node
(num17)[num,right of = num8,xshift= 2.5cm,fill=red!
1
0]
{
3
}
;
\node
(num18)[num,right of = num17,xshift= 0.6cm,fill=green!
1
0]
{
6
}
;
\node
(num19)[num,below of = num17,yshift=-0.6cm,fill=yellow!
1
0]
{
2
}
;
\node
(num20)[num,below of = num18,yshift= -0.6cm,fill=blue!
1
0]
{
2
}
;
\node
(num17)[num,right of = num8,xshift= 2.5cm,fill=red!
2
0]
{
3
}
;
\node
(num18)[num,right of = num17,xshift= 0.6cm,fill=green!
2
0]
{
6
}
;
\node
(num19)[num,below of = num17,yshift=-0.6cm,fill=yellow!
2
0]
{
2
}
;
\node
(num20)[num,below of = num18,yshift= -0.6cm,fill=blue!
2
0]
{
2
}
;
\node
[right of = num2,xshift= -0.7cm]
{}
;
...
...
Chapter11/Figures/figure-convolution-kernel.tex
查看文件 @
89d4bea0
\usetikzlibrary
{
decorations.pathreplacing
}
\tikzstyle
{
num
}
= [rectangle, minimum width = 0.8cm, minimum height = 0.8cm, text centered,align=center,thick,draw = black,fill=green!5]
\tikzstyle
{
num
}
= [rectangle, minimum width = 0.8cm, minimum height = 0.8cm, text centered,align=center,thick,draw = black,fill=green!
1
5]
\tikzstyle
{
att
}
= [rectangle, minimum width = 0.8cm, minimum height = 0.8cm, text centered,align=center]
...
...
Chapter11/Figures/figure-deep-vs-light.tex
查看文件 @
89d4bea0
...
...
@@ -30,7 +30,7 @@
\node
[anchor=north,font=
\tiny
,scale=1.1] at ([yshift=-0.2em]t2.south)
{
深度卷积
}
;
\end{scope}
\begin{scope}
[xshift=
4
cm]
\begin{scope}
[xshift=
5
cm]
\foreach
\point
in
{
0,1,2,3
}{
\node
[unit]
(l1
_
\point
) at (0, 0+
\point*
1.5em)
{}
;
\node
[unit]
(l2
_
\point
) at (0, 8em+
\point*
1.5em)
{}
;
...
...
Chapter11/Figures/figure-dimension-transformation.tex
查看文件 @
89d4bea0
\tikzstyle
{
num
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=green!
1
0]
\tikzstyle
{
num
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=green!
2
0]
\begin{tikzpicture}
[node distance = 0]
\node
[num]
at (0,0)
{
1
}
;
...
...
@@ -43,7 +43,7 @@
\node
[num]
at (2.4,3)
{
2
}
;
\node
[num]
at (3,3)
{
1
}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=purple!40,line width=0.08cm,fill=purple!
4
0,fill opacity=0.4]
at (0.6,2.4)
{}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=purple!40,line width=0.08cm,fill=purple!
5
0,fill opacity=0.4]
at (0.6,2.4)
{}
;
%\fill (4,1.5) circle (2pt);
\node
[] at (4,1.5)
{
*
}
;
...
...
Chapter11/Figures/figure-full-connection-vs-cnn-a.tex
查看文件 @
89d4bea0
\begin{tikzpicture}
[node distance = 0]
\foreach
\x
in
{
0,1,...,6
}{
\draw
[color=ublue,fill=blue!
1
5,thick]
(
\x
,0 )circle( 0.3);
\draw
[color=ublue,fill=blue!
2
5,thick]
(
\x
,0 )circle( 0.3);
}
\foreach
\x
in
{
1,2,...,5
}{
\draw
[color=ublue,thick]
(
\x
,2)circle( 0.3);
...
...
Chapter11/Figures/figure-full-connection-vs-cnn-b.tex
查看文件 @
89d4bea0
\begin{tikzpicture}
[node distance = 0]
\foreach
\x
in
{
0,1,...,6
}{
\draw
[color=ublue,fill=blue!
1
5,thick]
(
\x
,0 )circle( 0.3);
\draw
[color=ublue,fill=blue!
2
5,thick]
(
\x
,0 )circle( 0.3);
}
\foreach
\x
in
{
1,2,...,5
}{
\draw
[color=ublue,thick]
(
\x
,2)circle( 0.3);
...
...
Chapter11/Figures/figure-max-pooling.tex
查看文件 @
89d4bea0
...
...
@@ -2,32 +2,32 @@
\begin{tikzpicture}
[node distance = 0cm]
\node
(num1)[num,fill=red!
1
0]
{
1
}
;
\node
(num2)[num,below of = num1,yshift= -0.6cm,fill=red!
1
0]
{
5
}
;
\node
(num3)[num,right of = num1,xshift= 0.6cm,fill=red!
1
0]
{
0
}
;
\node
(num4)[num,below of = num3,yshift= -0.6cm,fill=red!
1
0]
{
6
}
;
\node
(num5)[num,right of = num3,xshift= 0.6cm,fill=green!
1
0]
{
4
}
;
\node
(num6)[num,below of = num5,yshift= -0.6cm,fill=green!
1
0]
{
7
}
;
\node
(num7)[num,right of = num5,xshift= 0.6cm,fill=green!
1
0]
{
5
}
;
\node
(num8)[num,below of = num7,yshift= -0.6cm,fill=green!
1
0]
{
8
}
;
\node
(num9)[num,below of = num2,yshift= -0.6cm,fill=yellow!
1
0]
{
3
}
;
\node
(num10)[num,below of = num9,yshift= -0.6cm,fill=yellow!
1
0]
{
1
}
;
\node
(num11)[num,right of = num9,xshift= 0.6cm,fill=yellow!
1
0]
{
2
}
;
\node
(num12)[num,below of = num11,yshift= -0.6cm,fill=yellow!
1
0]
{
2
}
;
\node
(num13)[num,right of = num11,xshift= 0.6cm,fill=blue!
1
0]
{
1
}
;
\node
(num14)[num,below of = num13,yshift= -0.6cm,fill=blue!
1
0]
{
3
}
;
\node
(num10)[num,right of = num13,xshift= 0.6cm,fill=blue!
1
0]
{
0
}
;
\node
(num16)[num,below of = num10,yshift= -0.6cm,fill=blue!
1
0]
{
4
}
;
\node
(num1)[num,fill=red!
2
0]
{
1
}
;
\node
(num2)[num,below of = num1,yshift= -0.6cm,fill=red!
2
0]
{
5
}
;
\node
(num3)[num,right of = num1,xshift= 0.6cm,fill=red!
2
0]
{
0
}
;
\node
(num4)[num,below of = num3,yshift= -0.6cm,fill=red!
2
0]
{
6
}
;
\node
(num5)[num,right of = num3,xshift= 0.6cm,fill=green!
2
0]
{
4
}
;
\node
(num6)[num,below of = num5,yshift= -0.6cm,fill=green!
2
0]
{
7
}
;
\node
(num7)[num,right of = num5,xshift= 0.6cm,fill=green!
2
0]
{
5
}
;
\node
(num8)[num,below of = num7,yshift= -0.6cm,fill=green!
2
0]
{
8
}
;
\node
(num9)[num,below of = num2,yshift= -0.6cm,fill=yellow!
2
0]
{
3
}
;
\node
(num10)[num,below of = num9,yshift= -0.6cm,fill=yellow!
2
0]
{
1
}
;
\node
(num11)[num,right of = num9,xshift= 0.6cm,fill=yellow!
2
0]
{
2
}
;
\node
(num12)[num,below of = num11,yshift= -0.6cm,fill=yellow!
2
0]
{
2
}
;
\node
(num13)[num,right of = num11,xshift= 0.6cm,fill=blue!
2
0]
{
1
}
;
\node
(num14)[num,below of = num13,yshift= -0.6cm,fill=blue!
2
0]
{
3
}
;
\node
(num10)[num,right of = num13,xshift= 0.6cm,fill=blue!
2
0]
{
0
}
;
\node
(num16)[num,below of = num10,yshift= -0.6cm,fill=blue!
2
0]
{
4
}
;
\draw
[->,thick]
([xshift=0.4cm,yshift=-0.4cm]num8.east)--([xshift=1.5cm,yshift=-0.4cm]num8.east);
\node
(num17)[num,right of = num8,xshift= 2.5cm,fill=red!
1
0]
{
6
}
;
\node
(num18)[num,right of = num17,xshift= 0.6cm,fill=green!
1
0]
{
8
}
;
\node
(num19)[num,below of = num17,yshift=-0.6cm,fill=yellow!
1
0]
{
3
}
;
\node
(num20)[num,below of = num18,yshift= -0.6cm,fill=blue!
1
0]
{
4
}
;
\node
(num17)[num,right of = num8,xshift= 2.5cm,fill=red!
2
0]
{
6
}
;
\node
(num18)[num,right of = num17,xshift= 0.6cm,fill=green!
2
0]
{
8
}
;
\node
(num19)[num,below of = num17,yshift=-0.6cm,fill=yellow!
2
0]
{
3
}
;
\node
(num20)[num,below of = num18,yshift= -0.6cm,fill=blue!
2
0]
{
4
}
;
\node
[right of = num20,xshift= 0.7cm]
{}
;
...
...
Chapter11/Figures/figure-padding-and-conv.tex
查看文件 @
89d4bea0
\tikzstyle
{
num
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=green!
1
0]
\tikzstyle
{
pad
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=blue!
1
0]
\tikzstyle
{
num
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=green!
2
0]
\tikzstyle
{
pad
}
= [minimum width = 0.6cm,minimum height = 0.6cm,draw,fill=blue!
2
0]
\begin{tikzpicture}
[node distance = 0]
\node
[pad]
at (-0.6,-0.6)
{
0
}
;
...
...
@@ -74,8 +74,8 @@
\node
[pad]
at (3,3.6)
{
0
}
;
\node
[pad]
at (3.6,3.6)
{
0
}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=purple!40,line width=0.08cm,fill=purple!
4
0,fill opacity=0.4]
at (0,3)
{}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=orange!40,line width=0.08cm,fill=orange!
4
0,fill opacity=0.4]
at (0.6,2.4)
{}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=purple!40,line width=0.08cm,fill=purple!
5
0,fill opacity=0.4]
at (0,3)
{}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=orange!40,line width=0.08cm,fill=orange!
5
0,fill opacity=0.4]
at (0.6,2.4)
{}
;
%\fill (4.55,1.5) circle (2pt);
\node
[] at (4.55,1.5)
{
*
}
;
...
...
Chapter11/Figures/figure-single-glu.tex
查看文件 @
89d4bea0
...
...
@@ -6,16 +6,16 @@
\tikzstyle
{
word
}
= [inner sep=0pt, font=
\scriptsize
,minimum height=
\bd
]
%\draw[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.2pt] (0cm,0cm) rectangle (0cm+6*\bd,0cm+9*\bd);
\draw
[fill=cyan!
1
0]
(0cm,0cm) -- (4*
\bd
,0cm) -- (4*
\bd
,8*
\bd
) -- (0cm, 8*
\bd
) -- (0cm,0cm);
\draw
[fill=cyan!
2
0]
(0cm,0cm) -- (4*
\bd
,0cm) -- (4*
\bd
,8*
\bd
) -- (0cm, 8*
\bd
) -- (0cm,0cm);
\draw
[cyan,step=\bd,line width=0.8pt]
(0cm,0cm) grid (0cm+4*
\bd
,0cm+8*
\bd
);
\draw
[fill=red!
5
]
(0cm,1*
\bd
) -- (4*
\bd
,1*
\bd
) -- (4*
\bd
,7*
\bd
) -- (0cm, 7*
\bd
) -- (0cm,1*
\bd
);
\draw
[red!
5
0,step=\bd,xshift=0cm,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=ugreen!
5
]
(7*
\bd
,
\bd
) -- (11*
\bd
,
\bd
) -- (11*
\bd
,7*
\bd
) -- (7*
\bd
, 7*
\bd
) -- (7*
\bd
,
\bd
);
\draw
[ugreen!
6
0,step=\bd,xshift=7*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=ugreen!
5
]
(11.5*
\bd
,
\bd
) -- (15.5*
\bd
,
\bd
) -- (15.5*
\bd
,7*
\bd
) -- (11.5*
\bd
, 7*
\bd
) -- (11.5*
\bd
,
\bd
);
\draw
[ugreen!
6
0,step=\bd,xshift=11.5*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=blue!
5
]
(18.5*
\bd
,
\bd
) -- (22.5*
\bd
,
\bd
) -- (22.5*
\bd
,7*
\bd
) -- (18.5*
\bd
, 7*
\bd
) -- (18.5*
\bd
,
\bd
);
\draw
[blue!
5
0,step=\bd,xshift=18.5*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=red!
10
]
(0cm,1*
\bd
) -- (4*
\bd
,1*
\bd
) -- (4*
\bd
,7*
\bd
) -- (0cm, 7*
\bd
) -- (0cm,1*
\bd
);
\draw
[red!
6
0,step=\bd,xshift=0cm,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=ugreen!
10
]
(7*
\bd
,
\bd
) -- (11*
\bd
,
\bd
) -- (11*
\bd
,7*
\bd
) -- (7*
\bd
, 7*
\bd
) -- (7*
\bd
,
\bd
);
\draw
[ugreen!
7
0,step=\bd,xshift=7*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=ugreen!
10
]
(11.5*
\bd
,
\bd
) -- (15.5*
\bd
,
\bd
) -- (15.5*
\bd
,7*
\bd
) -- (11.5*
\bd
, 7*
\bd
) -- (11.5*
\bd
,
\bd
);
\draw
[ugreen!
7
0,step=\bd,xshift=11.5*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[fill=blue!
10
]
(18.5*
\bd
,
\bd
) -- (22.5*
\bd
,
\bd
) -- (22.5*
\bd
,7*
\bd
) -- (18.5*
\bd
, 7*
\bd
) -- (18.5*
\bd
,
\bd
);
\draw
[blue!
6
0,step=\bd,xshift=18.5*\bd,yshift=\bd, line width=0.8pt]
(0cm, 0cm) grid (0cm+4*
\bd
,0cm+6*
\bd
);
\draw
[-,line width=0.6pt]
(4*
\bd
, 0.5*
\bd
) -- (5.5*
\bd
, 1.5*
\bd
) -- (4*
\bd
, 2.5*
\bd
);
...
...
@@ -44,7 +44,7 @@
\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)
{
\node
[inner sep=2pt,word,fill=green!
10
,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函数
\\
...
...
Chapter11/Figures/figure-standard-convolution-neural-network-module.tex
查看文件 @
89d4bea0
\tikzstyle
{
input
}
= [rectangle, minimum width = 1cm, minimum height = 3cm, text centered]
\tikzstyle
{
output
}
= [rectangle, minimum width = 1cm, minimum height = 3cm, text centered]
\tikzstyle
{
convolution
}
= [rectangle, minimum width =
0.7cm, minimum height = 2cm, text centered, fill = red!1
0, draw = black, thick]
\tikzstyle
{
activation
}
= [rectangle, minimum width =
0.7cm, minimum height = 2cm, text centered, fill = blue!1
0, draw = black, thick]
\tikzstyle
{
pooling
}
= [rectangle, thick, minimum width =
0.7cm, minimum height = 2cm, text centered, draw = black, fill = ugreen!1
0]
\tikzstyle
{
input
}
= [rectangle, minimum width = 1
.5
cm, minimum height = 3cm, text centered]
\tikzstyle
{
output
}
= [rectangle, minimum width = 1
.5
cm, minimum height = 3cm, text centered]
\tikzstyle
{
convolution
}
= [rectangle, minimum width =
1cm, minimum height = 2cm, text centered, fill = red!2
0, draw = black, thick]
\tikzstyle
{
activation
}
= [rectangle, minimum width =
1cm, minimum height = 2cm, text centered, fill = blue!2
0, draw = black, thick]
\tikzstyle
{
pooling
}
= [rectangle, thick, minimum width =
1cm, minimum height = 2cm, text centered, draw = black, fill = ugreen!2
0]
\tikzstyle
{
arrow
}
= [thick, ->, >=stealth]
\begin{tikzpicture}
[node distance = 0cm]
\node
(input)[input, align=center]
{
输
\\
入
}
;
\node
(convolution)[convolution,right of = input,xshift = 2cm, align=center]
{
卷
\\
积
\\
层
}
;
\node
(activation)[activation,right of = convolution,xshift = 2cm, align=center]
{
激
\\
活
\\
函
\\
数
}
;
\node
(pooling)[pooling,right of = activation,xshift = 2cm, align=center]
{
池
\\
化
\\
层
}
;
\node
(output)[output,right of = pooling,xshift= 2cm, align=center]
{
输
\\
出
}
;
\node
(convolution)[convolution,right of = input,xshift = 2
.5
cm, align=center]
{
卷
\\
积
\\
层
}
;
\node
(activation)[activation,right of = convolution,xshift = 2
.5
cm, align=center]
{
激
\\
活
\\
函
\\
数
}
;
\node
(pooling)[pooling,right of = activation,xshift = 2
.5
cm, align=center]
{
池
\\
化
\\
层
}
;
\node
(output)[output,right of = pooling,xshift= 2
.5
cm, align=center]
{
输
\\
出
}
;
\draw
[arrow] (input) -- ([xshift=-0.15cm]convolution.180);
\draw
[arrow] ([xshift=0.15cm]convolution.0) -- ([xshift=-0.15cm]activation.180);
...
...
Chapter11/Figures/figure-standard.tex
查看文件 @
89d4bea0
...
...
@@ -43,7 +43,7 @@
\node
[anchor=north,font=
\tiny
,scale=1.1] at ([yshift=-0.2em]t1.south)
{
(a) 标准卷积
}
;
\end{scope}
\begin{scope}
[xshift=
4
cm]
\begin{scope}
[xshift=
5
cm]
\foreach
\point
in
{
0,1,2
}{
\node
[unit]
(l1
_
\point
) at (0, 0+
\point*
1.5em)
{}
;
\node
[unit]
(l2
_
\point
) at (0, 6em+
\point*
1.5em)
{}
;
...
...
@@ -77,7 +77,7 @@
\node
[anchor=north,font=
\tiny
,scale=1.1] at ([yshift=-0.2em]t2.south)
{
(b) 深度卷积
}
;
\end{scope}
\begin{scope}
[xshift=
8
cm]
\begin{scope}
[xshift=
10
cm]
\foreach
\point
in
{
0,1,2
}{
\node
[unit]
(l1
_
\point
) at (0, 0+
\point*
1.5em)
{}
;
\node
[unit]
(l2
_
\point
) at (0, 6em+
\point*
1.5em)
{}
;
...
...
Chapter11/Figures/figure-use-cnn-in-nmt.tex
查看文件 @
89d4bea0
...
...
@@ -5,41 +5,41 @@
\begin{scope}
%\tikzstyle{every node}=[scale=0.8]
\tikzstyle
{
line
}
= [dash pattern=on 2pt off 1pt,line width=0.5pt]
\tikzstyle
{
cir
}
= [thin,fill=blue!
8
,draw,circle,minimum size =0.5em,drop shadow=
{
shadow xshift=0.15em, shadow yshift=-0.1em
}
]
\tikzstyle
{
cir
}
= [thin,fill=blue!
15
,draw,circle,minimum size =0.5em,drop shadow=
{
shadow xshift=0.15em, shadow yshift=-0.1em
}
]
\tikzstyle
{
word
}
= [inner sep=0pt, font=
\scriptsize
,minimum height=
\bcc
]
\draw
[fill=red!
8
,line width=0.2pt]
(0cm,0cm+1*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+7*
\bcc
);
\draw
[fill=cyan!
14
,line width=0.2pt]
(0cm,0cm) rectangle (0cm+4*
\bcc
,0cm+1*
\bcc
);
\draw
[fill=cyan!
14
,line width=0.2pt]
(0cm,0cm+7*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+8*
\bcc
);
\draw
[fill=red!
15
,line width=0.2pt]
(0cm,0cm+1*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+7*
\bcc
);
\draw
[fill=cyan!
20
,line width=0.2pt]
(0cm,0cm) rectangle (0cm+4*
\bcc
,0cm+1*
\bcc
);
\draw
[fill=cyan!
20
,line width=0.2pt]
(0cm,0cm+7*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+8*
\bcc
);
\draw
[step=\bcc]
(0cm,0cm) grid (0cm+4*
\bcc
,0cm+8*
\bcc
);
%\draw[line width=0.7pt] (0cm,0cm) rectangle (0cm+4*\bcc,0cm+8*\bcc);
\draw
[red!
5
0,line width=1.8pt]
(0cm,0cm+5*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+8*
\bcc
);
\draw
[ugreen!
5
0,line width=1.8pt]
(0cm,0cm+1*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+4*
\bcc
);
\draw
[red!
7
0,line width=1.8pt]
(0cm,0cm+5*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+8*
\bcc
);
\draw
[ugreen!
7
0,line width=1.8pt]
(0cm,0cm+1*
\bcc
) rectangle (0cm+4*
\bcc
,0cm+4*
\bcc
);
\draw
[fill=blue!
8
,xshift=5.0cm,yshift=1.0cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.0cm,yshift=1.0cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[step=\bcc,xshift=5.0cm,yshift=1.0cm]
(0cm,0cm) grid (0cm+1*
\bcc
,0cm+6*
\bcc
);
%\draw[line width=0.7pt,xshift=5.0cm,yshift=1.0cm] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+6*\bcc);
\draw
[fill=blue!
8
,xshift=5.2cm,yshift=0.8cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.2cm,yshift=0.8cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[step=\bcc,xshift=5.2cm,yshift=0.8cm]
(0cm,0cm) grid (0cm+1*
\bcc
,0cm+6*
\bcc
);
%\draw[line width=0.7pt,xshift=5.2cm,yshift=0.8cm] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+6*\bcc);
\draw
[ugreen!
5
0,line width=2pt,xshift=5.2cm,yshift=0.8cm]
(0cm,0cm+1*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+2*
\bcc
);
\draw
[ugreen!
7
0,line width=2pt,xshift=5.2cm,yshift=0.8cm]
(0cm,0cm+1*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+2*
\bcc
);
\draw
[fill=blue!
8
,xshift=5.4cm,yshift=0.6cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.4cm,yshift=0.6cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[step=\bcc,xshift=5.4cm,yshift=0.6cm]
(0cm,0cm) grid (0cm+1*
\bcc
,0cm+6*
\bcc
);
%\draw[line width=0.7pt,xshift=5.4cm,yshift=0.6cm] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+6*\bcc);
\draw
[fill=blue!
8
,xshift=5.6cm,yshift=0.4cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.6cm,yshift=0.4cm,line width=0.2pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[step=\bcc,xshift=5.6cm,yshift=0.4cm]
(0cm,0cm) grid (0cm+1*
\bcc
,0cm+6*
\bcc
);
%\draw[line width=0.7pt,xshift=5.6cm,yshift=0.4cm] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+6*\bcc);
\draw
[red!
5
0,line width=2pt,xshift=5.6cm,yshift=0.4cm]
(0cm,0cm+5*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[red!
7
0,line width=2pt,xshift=5.6cm,yshift=0.4cm]
(0cm,0cm+5*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[red!
5
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+8*
\bcc
) -- ([xshift=5.6cm,yshift=0.4cm]0cm,0cm+6*
\bcc
);
\draw
[red!
5
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+5*
\bcc
) -- ([xshift=5.6cm,yshift=0.4cm]0cm,0cm+5*
\bcc
);
\draw
[red!
7
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+8*
\bcc
) -- ([xshift=5.6cm,yshift=0.4cm]0cm,0cm+6*
\bcc
);
\draw
[red!
7
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+5*
\bcc
) -- ([xshift=5.6cm,yshift=0.4cm]0cm,0cm+5*
\bcc
);
\draw
[ugreen!
5
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+4*
\bcc
) -- ([xshift=5.2cm,yshift=0.8cm]0cm,0cm+2*
\bcc
);
\draw
[ugreen!
5
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+1*
\bcc
) -- ([xshift=5.2cm,yshift=0.8cm]0cm,0cm+1*
\bcc
);
\draw
[ugreen!
7
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+4*
\bcc
) -- ([xshift=5.2cm,yshift=0.8cm]0cm,0cm+2*
\bcc
);
\draw
[ugreen!
7
0,line width=0.5pt]
(0cm+4*
\bcc
,0cm+1*
\bcc
) -- ([xshift=5.2cm,yshift=0.8cm]0cm,0cm+1*
\bcc
);
\node
[word]
(w1) at (-0.5cm, 3.0cm)
{$
<
$
p
$
>
$}
;
\node
[word]
(w2) at ([yshift=-
\bcc
]w1)
{
今天
}
;
...
...
Chapter11/Figures/figure-use-cnn-in-sentence-classification.tex
查看文件 @
89d4bea0
...
...
@@ -5,7 +5,7 @@
\begin{scope}
%\tikzstyle{every node}=[scale=0.8]
\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
{
cir
}
= [thin,fill=blue!
15
,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=
\bcc
]
%\draw[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+6*\bcc,0cm+9*\bcc);
...
...
@@ -13,30 +13,30 @@
%\draw[red!60,line width=2pt,xshift=0.3cm,yshift=0.5cm] (0cm,0cm+2*\bcc) rectangle (0cm+6*\bcc,0cm+4*\bcc);
% 输入矩阵
\draw
[thick,fill=blue!
8
,line width=0.6pt]
(0cm,0cm) rectangle (0cm+6*
\bcc
,0cm+9*
\bcc
);
\draw
[thick,fill=blue!
15
,line width=0.6pt]
(0cm,0cm) rectangle (0cm+6*
\bcc
,0cm+9*
\bcc
);
\draw
[step=\bcc,gray]
(0cm,0cm) grid (0cm+6*
\bcc
,0cm+9*
\bcc
);
\draw
[red!
6
0,line width=2pt]
(0cm,0cm) rectangle (0cm+6*
\bcc
,0cm+2*
\bcc
);
\draw
[ugreen!
6
0,line width=2pt]
(0cm,0cm+3*
\bcc
) rectangle (0cm+6*
\bcc
,0cm+6*
\bcc
);
\draw
[red!
6
0,line width=2pt]
(0cm,0cm+7*
\bcc
) rectangle (0cm+6*
\bcc
,0cm+9*
\bcc
);
\draw
[red!
8
0,line width=2pt]
(0cm,0cm) rectangle (0cm+6*
\bcc
,0cm+2*
\bcc
);
\draw
[ugreen!
8
0,line width=2pt]
(0cm,0cm+3*
\bcc
) rectangle (0cm+6*
\bcc
,0cm+6*
\bcc
);
\draw
[red!
8
0,line width=2pt]
(0cm,0cm+7*
\bcc
) rectangle (0cm+6*
\bcc
,0cm+9*
\bcc
);
% 特征图
\draw
[fill=blue!
8
,xshift=5.0cm,yshift=1.3cm,line width=0.6pt]
(0cm,0cm-1*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.0cm,yshift=1.3cm,line width=0.6pt]
(0cm,0cm-1*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[step=\bcc,gray,xshift=5.0cm,yshift=1.3cm]
(0cm,0cm-1*
\bcc
) grid (0cm+1*
\bcc
,0cm+6*
\bcc
);
\draw
[ugreen!
6
0,line width=2pt,xshift=5.0cm,yshift=1.3cm]
(0cm,0cm+2*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+3*
\bcc
);
\draw
[ugreen!
8
0,line width=2pt,xshift=5.0cm,yshift=1.3cm]
(0cm,0cm+2*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+3*
\bcc
);
%最大池化
\draw
[gray,fill=blue!
8
,line width=0.6pt](8cm,2.2cm) -- (8.4cm, 2.2cm) -- (8.7cm,1.4cm) -- (8.3cm, 1.4cm) -- (8cm,2.2cm);
\draw
[gray,fill=blue!
15
,line width=0.6pt](8cm,2.2cm) -- (8.4cm, 2.2cm) -- (8.7cm,1.4cm) -- (8.3cm, 1.4cm) -- (8cm,2.2cm);
\draw
[gray](8.15cm,1.8cm) -- (8.55cm,1.8cm);
%\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
,line width=0.6pt](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.8cm) -- (11.3cm, 1.8cm) -- (11cm,2.2cm);
\draw
[gray,fill=blue!
15
,line width=0.6pt](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.8cm) -- (11.3cm, 1.8cm) -- (11cm,2.2cm);
%\draw [gray](11.15cm,1.8cm) -- (11.55cm,1.8cm);
%最大池化
\draw
[ugreen!
6
0,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bcc
,0cm+6*
\bcc
) -- (8cm,2.2cm);
\draw
[ugreen!
6
0,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bcc
,0cm-1*
\bcc
) -- (8.15cm,1.8cm);
\draw
[ugreen!
8
0,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bcc
,0cm+6*
\bcc
) -- (8cm,2.2cm);
\draw
[ugreen!
8
0,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bcc
,0cm-1*
\bcc
) -- (8.15cm,1.8cm);
%特征图
%\draw[fill=blue!8,xshift=5.2cm,yshift=1.0cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+6*\bcc);
...
...
@@ -45,25 +45,25 @@
%\draw[fill=blue!8,xshift=5.4cm,yshift=0.3cm,line width=0.6pt] (0cm,0cm) rectangle (0cm+1*\bcc,0cm+7*\bcc);
%\draw[step=\bcc,gray,xshift=5.4cm,yshift=0.3cm] (0cm,0cm) grid (0cm+1*\bcc,0cm+7*\bcc);
\draw
[fill=blue!
8
,xshift=5.6cm,yshift=0cm,line width=0.6pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+8*
\bcc
);
\draw
[fill=blue!
15
,xshift=5.6cm,yshift=0cm,line width=0.6pt]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+8*
\bcc
);
\draw
[step=\bcc,gray,xshift=5.6cm,yshift=0cm]
(0cm,0cm) grid (0cm+1*
\bcc
,0cm+8*
\bcc
);
\draw
[red!
6
0,line width=2pt,xshift=5.6cm,yshift=0cm]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+1*
\bcc
);
\draw
[red!
6
0,line width=2pt,xshift=5.6cm,yshift=0cm]
(0cm,0cm+7*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+8*
\bcc
);
\draw
[red!
8
0,line width=2pt,xshift=5.6cm,yshift=0cm]
(0cm,0cm) rectangle (0cm+1*
\bcc
,0cm+1*
\bcc
);
\draw
[red!
8
0,line width=2pt,xshift=5.6cm,yshift=0cm]
(0cm,0cm+7*
\bcc
) rectangle (0cm+1*
\bcc
,0cm+8*
\bcc
);
% 全连接线
\draw
[line]
(8.4cm, 2.2cm) -- (11.2cm,2.2cm);
\draw
[line]
(8.7cm,1.4cm) -- (11.3cm, 1.8cm);
%全连接上面的红虚线
\draw
[red!
6
0,line]
([xshift=5.6cm,yshift=0cm]0cm+1*
\bcc
,0cm+7*
\bcc
) -- (8.15cm,1.8cm);
\draw
[red!
6
0,line]
([xshift=5.6cm,yshift=0cm]0cm+1*
\bcc
,0cm) -- (8.3cm, 1.4cm);
\draw
[red!
8
0,line]
([xshift=5.6cm,yshift=0cm]0cm+1*
\bcc
,0cm+7*
\bcc
) -- (8.15cm,1.8cm);
\draw
[red!
8
0,line]
([xshift=5.6cm,yshift=0cm]0cm+1*
\bcc
,0cm) -- (8.3cm, 1.4cm);
% 特征图红色虚线
\draw
[red!
6
0,line]
(0cm+6*
\bcc
,0cm+9*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+8*
\bcc
);
\draw
[red!
6
0,line]
(0cm+6*
\bcc
,0cm+7*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+7*
\bcc
);
\draw
[red!
6
0,line]
(0cm+6*
\bcc
,0cm+2*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+1*
\bcc
);
\draw
[red!
6
0,line]
(0cm+6*
\bcc
,0cm) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm);
\draw
[ugreen!
6
0,line]
(0cm+6*
\bcc
,0cm+6*
\bcc
) -- ([xshift=5.0cm,yshift=1.3cm]0cm,0cm+3*
\bcc
);
\draw
[ugreen!
6
0,line]
(0cm+6*
\bcc
,0cm+3*
\bcc
) -- ([xshift=5.0cm,yshift=1.3cm]0cm,0cm+2*
\bcc
);
\draw
[red!
8
0,line]
(0cm+6*
\bcc
,0cm+9*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+8*
\bcc
);
\draw
[red!
8
0,line]
(0cm+6*
\bcc
,0cm+7*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+7*
\bcc
);
\draw
[red!
8
0,line]
(0cm+6*
\bcc
,0cm+2*
\bcc
) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+1*
\bcc
);
\draw
[red!
8
0,line]
(0cm+6*
\bcc
,0cm) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm);
\draw
[ugreen!
8
0,line]
(0cm+6*
\bcc
,0cm+6*
\bcc
) -- ([xshift=5.0cm,yshift=1.3cm]0cm,0cm+3*
\bcc
);
\draw
[ugreen!
8
0,line]
(0cm+6*
\bcc
,0cm+3*
\bcc
) -- ([xshift=5.0cm,yshift=1.3cm]0cm,0cm+2*
\bcc
);
%\draw[red!60,line] ([xshift=0.3cm,yshift=0.5cm]0cm+6*\bcc,0cm+4*\bcc) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+3*\bcc);
%\draw[red!60,line] ([xshift=0.3cm,yshift=0.5cm]0cm+6*\bcc,0cm+2*\bcc) -- ([xshift=5.6cm,yshift=0cm]0cm,0cm+2*\bcc);
...
...
Chapter12/Figures/figure-a-combination-of-position-encoding-and-word-encoding.tex
查看文件 @
89d4bea0
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnode
}
= [draw,minimum width=
3.5
em,minimum height=1.2em]
\tikzstyle
{
rnode
}
= [draw,minimum width=
4
em,minimum height=1.2em]
\node
[rnode,anchor=south west,fill=red!
2
0!white] (e1) at (0,0)
{
\scriptsize
{$
e
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
20!white] (e2) at ([xshift=1
em]e1.south east)
{
\scriptsize
{$
e
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
20!white] (e3) at ([xshift=1
em]e2.south east)
{
\scriptsize
{$
e
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
20!white] (e4) at ([xshift=1
em]e3.south east)
{
\scriptsize
{$
e
(
\textrm
{
的
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
20!white] (e5) at ([xshift=1
em]e4.south east)
{
\scriptsize
{$
e
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
3
0!white] (e1) at (0,0)
{
\scriptsize
{$
e
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
30!white] (e2) at ([xshift=1.5
em]e1.south east)
{
\scriptsize
{$
e
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
30!white] (e3) at ([xshift=1.5
em]e2.south east)
{
\scriptsize
{$
e
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
30!white] (e4) at ([xshift=1.5
em]e3.south east)
{
\scriptsize
{$
e
(
\textrm
{
的
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!
30!white] (e5) at ([xshift=1.5
em]e4.south east)
{
\scriptsize
{$
e
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (h1) at ([yshift=1.5em]e1.north west)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (h2) at ([yshift=1.5em]e2.north west)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (h3) at ([yshift=1.5em]e3.north west)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (h4) at ([yshift=1.5em]e4.north west)
{
\scriptsize
{$
h
(
\textrm
{
的
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (h5) at ([yshift=1.5em]e5.north west)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (h1) at ([yshift=1.5em]e1.north west)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (h2) at ([yshift=1.5em]e2.north west)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (h3) at ([yshift=1.5em]e3.north west)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (h4) at ([yshift=1.5em]e4.north west)
{
\scriptsize
{$
h
(
\textrm
{
的
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (h5) at ([yshift=1.5em]e5.north west)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\foreach
\x
in
{
1,2,3,4,5
}{
\node
[anchor=north] (plus
\x
) at ([yshift=-0em]e
\x
.south)
{
\scriptsize
{$
\mathbf
{
\oplus
}$}}
;
}
\node
[rnode,anchor=north,fill=yellow!
2
0!white] (pos1) at ([yshift=-1.1em]e1.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
1
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
2
0!white] (pos2) at ([yshift=-1.1em]e2.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
2
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
2
0!white] (pos3) at ([yshift=-1.1em]e3.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
3
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
2
0!white] (pos4) at ([yshift=-1.1em]e4.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
4
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
2
0!white] (pos5) at ([yshift=-1.1em]e5.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
5
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
3
0!white] (pos1) at ([yshift=-1.1em]e1.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
1
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
3
0!white] (pos2) at ([yshift=-1.1em]e2.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
2
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
3
0!white] (pos3) at ([yshift=-1.1em]e3.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
3
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
3
0!white] (pos4) at ([yshift=-1.1em]e4.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
4
)
$}}
;
\node
[rnode,anchor=north,fill=yellow!
3
0!white] (pos5) at ([yshift=-1.1em]e5.south)
{
\scriptsize
{$
\textrm
{
PE
}
(
5
)
$}}
;
\foreach
\x
in
{
1,2,3,4,5
}{
...
...
Chapter12/Figures/figure-calculation-of-context-vector-c.tex
查看文件 @
89d4bea0
...
...
@@ -2,13 +2,13 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnode
}
= [draw,minimum width=
3.5
em,minimum height=1.2em]
\tikzstyle
{
rnode
}
= [draw,minimum width=
4
em,minimum height=1.2em]
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key1) at (0,0)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key2) at ([xshift=1
em]key1.south east)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key3) at ([xshift=1
em]key2.south east)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key4) at ([xshift=2
em]key3.south east)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west] (key5) at ([xshift=1em]key4.south east)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key1) at (0,0)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key2) at ([xshift=1.5
em]key1.south east)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key3) at ([xshift=1.5
em]key2.south east)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key4) at ([xshift=3
em]key3.south east)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west] (key5) at ([xshift=1
.5
em]key4.south east)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[anchor=west] (sep1) at ([xshift=0.3em]key3.east)
{
\scriptsize
{$
\textbf
{
...
}$}}
;
...
...
@@ -17,17 +17,17 @@
\draw
[->] ([yshift=1pt,xshift=3pt]key5.north) .. controls +(90:1.8em) and +(90:1.8em) .. ([yshift=1pt]key2.north);
\draw
[->] ([yshift=1pt,xshift=6pt]key5.north) .. controls +(90:2.2em) and +(90:2.2em) .. ([yshift=1pt]key1.north);
\node
[anchor=south west] (alpha1) at ([xshift=-1
em]key1.north west)
{
\scriptsize
{$
\alpha
_
1
=
.
2
$}}
;
\node
[anchor=south west] (alpha2) at ([xshift=-1
em]key2.north west)
{
\scriptsize
{$
\alpha
_
2
=
.
3
$}}
;
\node
[anchor=south west] (alpha3) at ([xshift=-1
em]key3.north west)
{
\scriptsize
{$
\alpha
_
3
=
.
1
$}}
;
\node
[anchor=south west] (alpha4) at ([xshift=-1
em]key4.north west)
{
\scriptsize
{$
\alpha
_
i
=
.
3
$}}
;
\node
[anchor=south west] (alpha1) at ([xshift=-1
.2em]key1.north west)
{
\scriptsize
{$
\alpha
_
1
=
0
.
2
$}}
;
\node
[anchor=south west] (alpha2) at ([xshift=-1
.2em]key2.north west)
{
\scriptsize
{$
\alpha
_
2
=
0
.
3
$}}
;
\node
[anchor=south west] (alpha3) at ([xshift=-1
.2em]key3.north west)
{
\scriptsize
{$
\alpha
_
3
=
0
.
1
$}}
;
\node
[anchor=south west] (alpha4) at ([xshift=-1
.2em]key4.north west)
{
\scriptsize
{$
\alpha
_
i
=
0
.
3
$}}
;
\vspace
{
0.5em
}
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key6) at ([yshift=2em]key1.north west)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key7) at ([yshift=2em]key2.north west)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key8) at ([yshift=2em]key3.north west)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key9) at ([yshift=2em]key4.north west)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key6) at ([yshift=2em]key1.north west)
{
\scriptsize
{$
h
(
\textrm
{
广州
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key7) at ([yshift=2em]key2.north west)
{
\scriptsize
{$
h
(
\textrm
{
到
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key8) at ([yshift=2em]key3.north west)
{
\scriptsize
{$
h
(
\textrm
{
沈阳
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key9) at ([yshift=2em]key4.north west)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[rnode,anchor=south west] (key10) at ([yshift=2em]key5.north west)
{
\scriptsize
{$
h
(
\textrm
{
机票
}
)
$}}
;
\node
[anchor=west] (sep1) at ([xshift=0.3em]key8.east)
{
\scriptsize
{$
\textbf
{
...
}$}}
;
...
...
@@ -37,10 +37,10 @@
\draw
[->] ([yshift=1pt,xshift=3pt]key10.north) .. controls +(90:1.8em) and +(90:1.8em) .. ([yshift=1pt]key7.north);
\draw
[->] ([yshift=1pt,xshift=6pt]key10.north) .. controls +(90:2.2em) and +(90:2.2em) .. ([yshift=1pt]key6.north);
\node
[anchor=south west] (alpha5) at ([xshift=-1
em]key6.north west)
{
\scriptsize
{$
\alpha
_
1
=
.
1
$}}
;
\node
[anchor=south west] (alpha6) at ([xshift=-1
em]key7.north west)
{
\scriptsize
{$
\alpha
_
2
=
.
3
$}}
;
\node
[anchor=south west] (alpha7) at ([xshift=-1
em]key8.north west)
{
\scriptsize
{$
\alpha
_
3
=
.
2
$}}
;
\node
[anchor=south west] (alpha8) at ([xshift=-1
em]key9.north west)
{
\scriptsize
{$
\alpha
_
i
=
.
3
$}}
;
\node
[anchor=south west] (alpha5) at ([xshift=-1
.2em]key6.north west)
{
\scriptsize
{$
\alpha
_
1
=
0
.
1
$}}
;
\node
[anchor=south west] (alpha6) at ([xshift=-1
.2em]key7.north west)
{
\scriptsize
{$
\alpha
_
2
=
0
.
3
$}}
;
\node
[anchor=south west] (alpha7) at ([xshift=-1
.2em]key8.north west)
{
\scriptsize
{$
\alpha
_
3
=
0
.
2
$}}
;
\node
[anchor=south west] (alpha8) at ([xshift=-1
.2em]key9.north west)
{
\scriptsize
{$
\alpha
_
i
=
0
.
3
$}}
;
\end{scope}
\end{tikzpicture}
...
...
Chapter12/Figures/figure-comparison-of-the-number-of-padding-in-batch.tex
查看文件 @
89d4bea0
...
...
@@ -4,7 +4,7 @@
\begin{scope}
[scale=1.5]
{
\Large
\tikzstyle
{
snode
}
= [draw,inner sep=1pt,minimum width=3em,minimum height=0.5em,rounded corners=1pt,fill=green!
3
0!white]
\tikzstyle
{
snode
}
= [draw,inner sep=1pt,minimum width=3em,minimum height=0.5em,rounded corners=1pt,fill=green!
4
0!white]
\tikzstyle
{
pnode
}
= [draw,inner sep=1pt,minimum width=1em,minimum height=0.5em,rounded corners=1pt]
\node
[anchor=west,snode] (s1) at (0,0)
{}
;
\node
[anchor=north west,snode,minimum width=6.5em] (s2) at ([yshift=-0.3em]s1.south west)
{}
;
...
...
@@ -15,7 +15,7 @@
\node
[anchor=west,pnode,minimum width=3em] (p1) at ([xshift=0.3em]s1.east)
{}
;
\node
[anchor=west,pnode,minimum width=4em] (p3) at ([xshift=0.3em]s3.east)
{}
;
\node
[anchor=west,snode,minimum width=5em] (s4) at ([xshift=
4
em]p1.east)
{}
;
\node
[anchor=west,snode,minimum width=5em] (s4) at ([xshift=
5
em]p1.east)
{}
;
\node
[anchor=north west,snode,minimum width=5em] (s5) at ([yshift=-0.3em]s4.south west)
{}
;
\node
[anchor=north west,snode,minimum width=6.5em] (s6) at ([yshift=-0.3em]s5.south west)
{}
;
...
...
Chapter12/Figures/figure-decode-of-transformer.tex
查看文件 @
89d4bea0
...
...
@@ -3,14 +3,14 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.
1
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.
7
em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\node
[rnnnode,anchor=west] (h1) at (0,0)
{
\tiny
{$
\mathbi
{
h
}_
1
$}}
;
\node
[rnnnode,anchor=west] (h2) at ([xshift=1em]h1.east)
{
\tiny
{$
\mathbi
{
h
}_
2
$}}
;
\node
[rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east)
{
\tiny
{$
\mathbi
{
h
}_
3
$}}
;
\node
[rnnnode,anchor=west] (h2) at ([xshift=1
.5
em]h1.east)
{
\tiny
{$
\mathbi
{
h
}_
2
$}}
;
\node
[rnnnode,anchor=west] (h3) at ([xshift=1
.5
em]h2.east)
{
\tiny
{$
\mathbi
{
h
}_
3
$}}
;
\node
[rnnnode,anchor=north,fill=green!20] (e1) at ([yshift=-1em]h1.south)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e2) at ([xshift=1em]e1.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e2) at ([xshift=1
.5
em]e1.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1
.5
em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[anchor=north,inner sep=2pt] (w1) at ([yshift=-0.6em]e1.south)
{
\tiny
{
你
}}
;
\node
[anchor=north,inner sep=2pt] (w2) at ([yshift=-0.6em]e2.south)
{
\tiny
{
好
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{$
\langle
$
eos
$
\rangle
$}}
;
...
...
@@ -33,14 +33,14 @@
\node
[anchor=south] (encoder) at ([xshift=-0.2em]h1.north west)
{
\scriptsize
{
\textbf
{
编码器
}}}
;
{
\node
[rnnnode,anchor=west,fill=green!20] (t1) at ([xshift=3em]e3.east)
{
\tiny
{$
e
_
y
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (t1) at ([xshift=3
.5
em]e3.east)
{
\tiny
{$
e
_
y
()
$}}
;
}
{
\node
[rnnnode,anchor=west,fill=green!20] (t2) at ([xshift=1.
5
em]t1.east)
{
\tiny
{$
e
_
y
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (t2) at ([xshift=1.
8
em]t1.east)
{
\tiny
{$
e
_
y
()
$}}
;
}
{
\node
[rnnnode,anchor=west,fill=green!20] (t3) at ([xshift=1.
5
em]t2.east)
{
\tiny
{$
e
_
y
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (t4) at ([xshift=1.
5
em]t3.east)
{
\tiny
{$
e
_
y
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (t3) at ([xshift=1.
8
em]t2.east)
{
\tiny
{$
e
_
y
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (t4) at ([xshift=1.
8
em]t3.east)
{
\tiny
{$
e
_
y
()
$}}
;
%\node [anchor=west,inner sep=2pt] (t5) at ([xshift=0.3em]t4.east) {\tiny{...}};
}
{
...
...
Chapter12/Figures/figure-dependencies-between-words-in-a-recurrent-neural-network.tex
查看文件 @
89d4bea0
...
...
@@ -3,11 +3,11 @@
\begin{tikzpicture}
\begin{scope}
\node
[anchor=west] (w0) at (0,0)
{$
w
_
1
$}
;
\node
[anchor=west] (w1) at ([xshift=
0.5
em]w0.east)
{$
w
_
2
$}
;
\node
[anchor=west] (w2) at ([xshift=
0.5
em]w1.east)
{$
w
_
3
$}
;
\node
[anchor=west] (w3) at ([xshift=
0.5
em]w2.east)
{$
...
$}
;
\node
[anchor=west] (w4) at ([xshift=
0.5
em]w3.east)
{$
w
_{
m
-
1
}$}
;
\node
[anchor=west,fill=green!
2
0!white] (w5) at ([xshift=0.5em]w4.east)
{$
w
_{
m
}$}
;
\node
[anchor=west] (w1) at ([xshift=
1
em]w0.east)
{$
w
_
2
$}
;
\node
[anchor=west] (w2) at ([xshift=
1
em]w1.east)
{$
w
_
3
$}
;
\node
[anchor=west] (w3) at ([xshift=
1
em]w2.east)
{$
...
$}
;
\node
[anchor=west] (w4) at ([xshift=
1
em]w3.east)
{$
w
_{
m
-
1
}$}
;
\node
[anchor=west,fill=green!
3
0!white] (w5) at ([xshift=0.5em]w4.east)
{$
w
_{
m
}$}
;
\draw
[->,thick,red] (w1.north).. controls +(130:0.5) and +(50:0.5) .. (w0.north);
\draw
[->,thick,red] (w2.north).. controls +(130:0.5) and +(50:0.5) .. (w1.north);
\draw
[->,thick,red] ([yshift=0.2em]w3.north).. controls +(130:0.5) and +(50:0.5) .. (w2.north);
...
...
Chapter12/Figures/figure-dependencies-between-words-of-attention.tex
查看文件 @
89d4bea0
...
...
@@ -3,11 +3,11 @@
\begin{tikzpicture}
\begin{scope}
\node
[anchor=west] (w0) at (0,-2)
{$
w
_
1
$}
;
\node
[anchor=west] (w1) at ([xshift=
0.5
em]w0.east)
{$
w
_
2
$}
;
\node
[anchor=west] (w2) at ([xshift=
0.5
em]w1.east)
{$
w
_
3
$}
;
\node
[anchor=west] (w3) at ([xshift=
0.5
em]w2.east)
{$
...
$}
;
\node
[anchor=west] (w4) at ([xshift=
0.5
em]w3.east)
{$
w
_{
m
-
1
}$}
;
\node
[anchor=west,fill=green!
2
0!white] (w5) at ([xshift=0.5em]w4.east)
{$
w
_{
m
}$}
;
\node
[anchor=west] (w1) at ([xshift=
1
em]w0.east)
{$
w
_
2
$}
;
\node
[anchor=west] (w2) at ([xshift=
1
em]w1.east)
{$
w
_
3
$}
;
\node
[anchor=west] (w3) at ([xshift=
1
em]w2.east)
{$
...
$}
;
\node
[anchor=west] (w4) at ([xshift=
1
em]w3.east)
{$
w
_{
m
-
1
}$}
;
\node
[anchor=west,fill=green!
3
0!white] (w5) at ([xshift=0.5em]w4.east)
{$
w
_{
m
}$}
;
\draw
[->,thick,red] (w5.north).. controls +(100:0.85) and +(50:0.85) .. (w0.north);
\draw
[->,thick,red] (w5.north).. controls +(110:0.75) and +(50:0.75) .. (w1.north);
\draw
[->,thick,red] (w5.north).. controls +(110:0.75) and +(50:0.75) .. (w2.north);
...
...
Chapter12/Figures/figure-different-regularization-methods.tex
查看文件 @
89d4bea0
...
...
@@ -3,12 +3,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
lnode
}
= [minimum height=1.5em,minimum width=3em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
2
0];
\tikzstyle
{
lnode
}
= [minimum height=1.5em,minimum width=3em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
3
0];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[lnode,anchor=west] (l1) at (0,0)
{
\scriptsize
{
子层
}}
;
\node
[lnode,anchor=west] (l2) at ([xshift=3em]l1.east)
{
\scriptsize
{
层标准化
}}
;
\node
[lnode,anchor=west] (l3) at ([xshift=
4
em]l2.east)
{
\scriptsize
{
层标准化
}}
;
\node
[lnode,anchor=west] (l3) at ([xshift=
6
em]l2.east)
{
\scriptsize
{
层标准化
}}
;
\node
[lnode,anchor=west] (l4) at ([xshift=1.5em]l3.east)
{
\scriptsize
{
子层
}}
;
\node
[anchor=west] (plus1) at ([xshift=0.9em]l1.east)
{
\scriptsize
{$
\mathbf
{
\oplus
}$}}
;
...
...
Chapter12/Figures/figure-example-of-self-attention-mechanism-calculation.tex
查看文件 @
89d4bea0
...
...
@@ -3,15 +3,15 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
rnode
}
= [draw,minimum width=
2.8
em,minimum height=1.2em]
\tikzstyle
{
rnode
}
= [draw,minimum width=
3.5
em,minimum height=1.2em]
\node
[rnode,anchor=south west,fill=green!
2
0!white] (key11) at (0,0)
{
\scriptsize
{$
h
(
\textrm
{
他
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key12) at ([xshift=0.8
em]key11.south east)
{
\scriptsize
{$
h
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key13) at ([xshift=0.8
em]key12.south east)
{
\scriptsize
{$
h
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key14) at ([xshift=0.8
em]key13.south east)
{
\scriptsize
{$
h
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
20!white] (key15) at ([xshift=0.8
em]key14.south east)
{
\scriptsize
{$
h
(
\textrm
{
学
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
3
0!white] (key11) at (0,0)
{
\scriptsize
{$
h
(
\textrm
{
他
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key12) at ([xshift=1.5
em]key11.south east)
{
\scriptsize
{$
h
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key13) at ([xshift=1.5
em]key12.south east)
{
\scriptsize
{$
h
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key14) at ([xshift=1.5
em]key13.south east)
{
\scriptsize
{$
h
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!
30!white] (key15) at ([xshift=1.5
em]key14.south east)
{
\scriptsize
{$
h
(
\textrm
{
学
}
)
$}}
;
\node
[rnode,anchor=east] (query1) at ([xshift=-1em]key11.west)
{
\scriptsize
{$
h
(
\textrm
{
他
}
)
$}}
;
...
...
Chapter12/Figures/figure-lrate-of-transformer.tex
查看文件 @
89d4bea0
...
...
@@ -4,7 +4,7 @@
\begin{tikzpicture}
\footnotesize
{
\begin{axis}
[
width=.
60
\textwidth
,
width=.
8
\textwidth
,
height=.40
\textwidth
,
legend style=
{
at=
{
(0.60,0.08)
}
, anchor=south west
}
,
xlabel=
{
\footnotesize
{
更新步数 (10k)
}}
,
...
...
Chapter12/Figures/figure-multi-head-attention-model.tex
查看文件 @
89d4bea0
...
...
@@ -2,29 +2,31 @@
\begin{tikzpicture}
\begin{scope}
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
20!white,text=ugreen!20!white
] (Linear0) at (0,0)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
20!white,draw,inner sep=4pt,text=ugreen!20!white
] (Linear01) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear0.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
20!white,draw,inner sep=4pt
] (Linear02) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear01.south west)
{
\footnotesize
{
Linear
}}
;
%
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
30!white,text=ugreen!30!white,minimum width=4em
] (Linear0) at (0,0)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
30!white,draw,inner sep=4pt,text=ugreen!30!white,minimum width=4em
] (Linear01) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear0.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
30!white,draw,inner sep=4pt,minimum width=4em
] (Linear02) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear01.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=north] (Q) at ([xshift=0em,yshift=-1em]Linear02.south)
{
\footnotesize
{$
\mathbi
{
Q
}$}}
;
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
20!white,text=ugreen!20!white
] (Linear1) at ([xshift=1.5em]Linear0.east)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
20!white,draw,inner sep=4pt,text=ugreen!20!white
] (Linear11) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear1.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
20!white,draw,inner sep=4pt
] (Linear12) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear11.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
30!white,text=ugreen!30!white,minimum width=4em
] (Linear1) at ([xshift=1.5em]Linear0.east)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
30!white,draw,inner sep=4pt,text=ugreen!30!white,minimum width=4em
] (Linear11) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear1.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
30!white,draw,inner sep=4pt,minimum width=4em
] (Linear12) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear11.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=north] (K) at ([xshift=0em,yshift=-1em]Linear12.south)
{
\footnotesize
{$
\mathbi
{
K
}$}}
;
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
20!white,text=ugreen!20!white
] (Linear2) at ([xshift=1.5em]Linear1.east)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
20!white,draw,inner sep=4pt,text=ugreen!20!white
] (Linear21) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear2.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
20!white,draw,inner sep=4pt
] (Linear22) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear21.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=west,draw=black!30,inner sep=4pt,fill=ugreen!
30!white,text=ugreen!30!white,minimum width=4em
] (Linear2) at ([xshift=1.5em]Linear1.east)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,draw=black!50,fill=ugreen!
30!white,draw,inner sep=4pt,text=ugreen!30!white,minimum width=4em
] (Linear21) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear2.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south west,fill=ugreen!
30!white,draw,inner sep=4pt,minimum width=4em
] (Linear22) at ([shift=
{
(-0.2em,-0.2em)
}
]Linear21.south west)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=north] (V) at ([xshift=0em,yshift=-1em]Linear22.south)
{
\footnotesize
{$
\mathbi
{
V
}$}}
;
\node
[anchor=south,draw=black!30,minimum width=12em,minimum height=2em,inner sep=4pt,fill=blue!20!white] (Scale) at ([yshift=1em]Linear1.north)
{
\footnotesize
{}}
;
\node
[anchor=south west,draw=black!50,minimum width=12em,minimum height=2em,fill=blue!20!white,draw,inner sep=4pt] (Scale1) at ([shift=
{
(-0.2em,-0.2em)
}
]Scale.south west)
{
\footnotesize
{}}
;
\node
[anchor=south west,fill=blue!20!white,draw,minimum width=12em,minimum height=2em,inner sep=4pt] (Scale2) at ([shift=
{
(-0.2em,-0.2em)
}
]Scale1.south west)
{
\footnotesize
{
Scaled Dot-Product Attention
}}
;
% scaled dot-product attention
\node
[anchor=south,draw=black!30,minimum width=16em,minimum height=2em,inner sep=4pt,fill=blue!30!white] (Scale) at ([yshift=1em]Linear1.north)
{
\footnotesize
{}}
;
\node
[anchor=south west,draw=black!50,minimum width=16em,minimum height=2em,fill=blue!30!white,draw,inner sep=4pt] (Scale1) at ([shift=
{
(-0.2em,-0.2em)
}
]Scale.south west)
{
\footnotesize
{}}
;
\node
[anchor=south west,fill=blue!30!white,draw,minimum width=16em,minimum height=2em,inner sep=4pt] (Scale2) at ([shift=
{
(-0.2em,-0.2em)
}
]Scale1.south west)
{
\footnotesize
{
Scaled Dot-Product Attention
}}
;
\node
[anchor=south,draw,minimum width=4em,inner sep=4pt,fill=yellow!30] (Concat) at ([yshift=1em]Scale2.north)
{
\footnotesize
{
Concat
}}
;
%
\node
[anchor=south,draw,minimum width=6em,inner sep=4pt,fill=yellow!30] (Concat) at ([yshift=1em]Scale2.north)
{
\footnotesize
{
Concat
}}
;
\node
[anchor=south,draw,minimum width=
4em,inner sep=4pt,fill=ugreen!2
0!white] (Linear) at ([yshift=1em]Concat.north)
{
\footnotesize
{
Linear
}}
;
\node
[anchor=south,draw,minimum width=
6em,inner sep=4pt,fill=ugreen!3
0!white] (Linear) at ([yshift=1em]Concat.north)
{
\footnotesize
{
Linear
}}
;
\draw
[->] ([yshift=0.1em]Q.north) -- ([yshift=-0.1em]Linear02.south);
...
...
Chapter12/Figures/figure-point-product-attention-model.tex
查看文件 @
89d4bea0
...
...
@@ -6,13 +6,13 @@
\begin{tikzpicture}
\begin{scope}
\node
[anchor=south west,fill=white,draw,inner sep=4pt,minimum width=4em,fill=blue!2
0
!white] (MatMul) at (0,0)
{
\tiny
{
MatMul
}}
;
\node
[anchor=south west,fill=white,draw,inner sep=4pt,minimum width=4em,fill=blue!2
5
!white] (MatMul) at (0,0)
{
\tiny
{
MatMul
}}
;
\node
[anchor=north] (Q1) at ([xshift=-1.4em,yshift=-1em]MatMul.south)
{
\footnotesize
{$
\mathbi
{
Q
}$}}
;
\node
[anchor=north] (K1) at ([xshift=1.4em,yshift=-1em]MatMul.south)
{
\footnotesize
{$
\mathbi
{
K
}$}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=yellow!
30
,minimum width=2.5em] (Scale3) at ([yshift=1em]MatMul.north)
{
\tiny
{
Scale
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=purple!2
0
,minimum width=3.5em] (Mask) at ([yshift=0.8em]Scale3.north)
{
\tiny
{
Mask(opt.)
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=ugreen!2
0
!white] (SoftMax) at ([yshift=1em]Mask.north)
{
\tiny
{
SoftMax
}}
;
\node
[anchor=south,draw,minimum width=4em,inner sep=4pt,fill=blue!2
0
!white] (MatMul1) at ([xshift=1.7em,yshift=1em]SoftMax.north)
{
\tiny
{
MatMul
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=yellow!
25
,minimum width=2.5em] (Scale3) at ([yshift=1em]MatMul.north)
{
\tiny
{
Scale
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=purple!2
5
,minimum width=3.5em] (Mask) at ([yshift=0.8em]Scale3.north)
{
\tiny
{
Mask(opt.)
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=ugreen!2
5
!white] (SoftMax) at ([yshift=1em]Mask.north)
{
\tiny
{
SoftMax
}}
;
\node
[anchor=south,draw,minimum width=4em,inner sep=4pt,fill=blue!2
5
!white] (MatMul1) at ([xshift=1.7em,yshift=1em]SoftMax.north)
{
\tiny
{
MatMul
}}
;
\node
[anchor=north] (V1) at ([xshift=2em]K1.north)
{
\footnotesize
{$
\mathbi
{
V
}$}}
;
\node
[anchor=north] (null) at ([yshift=0.8em]MatMul1.north)
{}
;
...
...
@@ -26,13 +26,13 @@
\draw
[->] ([yshift=0.1em]MatMul1.north) -- ([yshift=0.8em]MatMul1.north);
{
\node
[anchor=east] (line1) at ([xshift=-
4
em,yshift=1em]MatMul.west)
{
\scriptsize
{
自注意力机制的Query
}}
;
\node
[anchor=east] (line1) at ([xshift=-
5
em,yshift=1em]MatMul.west)
{
\scriptsize
{
自注意力机制的Query
}}
;
\node
[anchor=north west] (line2) at ([yshift=0.3em]line1.south west)
{
\scriptsize
{
Key和Value均来自同一句
}}
;
\node
[anchor=north west] (line3) at ([yshift=0.3em]line2.south west)
{
\scriptsize
{
子,编码-解码注意力机制
}}
;
\node
[anchor=north west] (line4) at ([yshift=0.3em]line3.south west)
{
\scriptsize
{
与前面讲的一样
}}
;
}
{
\node
[anchor=west] (line11) at ([xshift=
3
em,yshift=0em]MatMul.east)
{
\scriptsize
{
Query和Key的转置进
}}
;
\node
[anchor=west] (line11) at ([xshift=
5
em,yshift=0em]MatMul.east)
{
\scriptsize
{
Query和Key的转置进
}}
;
\node
[anchor=north west] (line12) at ([yshift=0.3em]line11.south west)
{
\scriptsize
{
行点积,得到句子内部
}}
;
\node
[anchor=north west] (line13) at ([yshift=0.3em]line12.south west)
{
\scriptsize
{
各个位置的相关性
}}
;
}
...
...
@@ -57,28 +57,28 @@
\begin{pgfonlayer}
{
background
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!
1
0,drop shadow,draw=ugreen,minimum width=10em] [fit = (line1) (line2) (line3) (line4)] (box1)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!
2
0,drop shadow,draw=ugreen,minimum width=10em] [fit = (line1) (line2) (line3) (line4)] (box1)
{}
;
\node
[rectangle,inner sep=0.1em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (Q1) (K1) (V1)] (box0)
{}
;
\draw
[->,dotted,very thick,ugreen] ([yshift=-1.5em,xshift=
1
.8em]box1.east) -- ([yshift=-1.5em,xshift=0.1em]box1.east);
\draw
[->,dotted,very thick,ugreen] ([yshift=-1.5em,xshift=
2
.8em]box1.east) -- ([yshift=-1.5em,xshift=0.1em]box1.east);
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=blue!2
0
!white,drop shadow,draw=blue] [fit = (line11) (line12) (line13)] (box2)
{}
;
\draw
[->,dotted,very thick,blue] ([yshift=1em,xshift=-
2
.8em]box2.west) -- ([yshift=1em,xshift=-0.1em]box2.west);
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=blue!2
5
!white,drop shadow,draw=blue] [fit = (line11) (line12) (line13)] (box2)
{}
;
\draw
[->,dotted,very thick,blue] ([yshift=1em,xshift=-
4
.8em]box2.west) -- ([yshift=1em,xshift=-0.1em]box2.west);
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=yellow!2
0
,drop shadow,draw=black] [fit = (line21) (line22) (line23)] (box3)
{}
;
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=yellow!2
5
,drop shadow,draw=black] [fit = (line21) (line22) (line23)] (box3)
{}
;
\draw
[->,dotted,very thick,black] ([xshift=0.1em]Scale3.east) .. controls +(east:1) and +(west:1) .. ([yshift=1.0em]box3.west) ;
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=red!
1
0,drop shadow,draw=red] [fit = (line31) (line32) (line33) (line34)] (box4)
{}
;
\draw
[->,dotted,very thick,red] ([yshift=-1.2em,xshift=
2
.2em]box4.east) -- ([yshift=-1.2em,xshift=0.1em]box4.east);
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=red!
2
0,drop shadow,draw=red] [fit = (line31) (line32) (line33) (line34)] (box4)
{}
;
\draw
[->,dotted,very thick,red] ([yshift=-1.2em,xshift=
3
.2em]box4.east) -- ([yshift=-1.2em,xshift=0.1em]box4.east);
}
{
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=blue!2
0
!white,drop shadow,draw=blue] [fit = (line41) (line42)] (box5)
{}
;
\draw
[->,dotted,very thick,blue] ([yshift=-0.3em,xshift=-
1
em]box5.west) -- ([yshift=-0.3em,xshift=-0.1em]box5.west);
\node
[rectangle,inner sep=0.2em,rounded corners=1pt,fill=blue!2
5
!white,drop shadow,draw=blue] [fit = (line41) (line42)] (box5)
{}
;
\draw
[->,dotted,very thick,blue] ([yshift=-0.3em,xshift=-
3
em]box5.west) -- ([yshift=-0.3em,xshift=-0.1em]box5.west);
}
\end{pgfonlayer}
...
...
Chapter12/Figures/figure-position-of-difference-and-layer-regularization-in-the-model.tex
查看文件 @
89d4bea0
...
...
@@ -4,12 +4,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
2
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
2
0];
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
3
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
3
0];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
outputnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
1
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
5
!white];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
2
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
10
!white];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[Sanode,anchor=west] (sa1) at (0,0)
{
\tiny
{$
\textbf
{
Self
-
Attention
}$}}
;
...
...
Chapter12/Figures/figure-position-of-feedforward-neural-network-in-the-model.tex
查看文件 @
89d4bea0
...
...
@@ -2,12 +2,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
2
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
2
0];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
2
0];
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
3
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
3
0];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
3
0];
\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!
1
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
5
!white];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
2
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
10
!white];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[Sanode,anchor=west] (sa1) at (0,0)
{
\tiny
{$
\textbf
{
Self
-
Attention
}$}}
;
...
...
Chapter12/Figures/figure-position-of-self-attention-mechanism-in-the-model.tex
查看文件 @
89d4bea0
...
...
@@ -3,12 +3,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
2
0];
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
3
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
outputnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
1
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
5
!white];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
2
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
10
!white];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[Sanode,anchor=west] (sa1) at (0,0)
{
\tiny
{$
\textbf
{
Self
-
Attention
}$}}
;
...
...
Chapter12/Figures/figure-process-of-5.tex
查看文件 @
89d4bea0
...
...
@@ -7,9 +7,9 @@
\node
(tbq) at ([xshift=0.5em,yshift=0]atten.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbq.north)
{$
\mathbi
{
Q
}$}
;
...
...
@@ -20,9 +20,9 @@
\node
(tbk) at ([xshift=1em,yshift=0]tbq.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
blue!
2
0
}
\\
\hline
\rowcolor
{
blue!
2
0
}
\\
\hline
\rowcolor
{
blue!
2
0
}
\\
\hline
\rowcolor
{
blue!
3
0
}
\\
\hline
\rowcolor
{
blue!
3
0
}
\\
\hline
\rowcolor
{
blue!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbk.north)
{$
\mathbi
{
K
}$}
;
...
...
@@ -33,9 +33,9 @@
\node
(tbv) at ([xshift=1em,yshift=0]tbk.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv.north)
{$
\mathbi
{
V
}$}
;
...
...
@@ -51,9 +51,9 @@
\node
(tbq2) at ([xshift=0.5em,yshift=2em]sof1.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
2
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\rowcolor
{
yellow!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbq2.north)
{$
\mathbi
{
Q
}$}
;
...
...
@@ -66,7 +66,7 @@
\node
(tbk2) at ([xshift=2em,yshift=0em]times.east)
{
\begin{tabular}
{
|l|l|l|
}
\hline
\cellcolor
{
blue!
20
}
&
\cellcolor
{
blue!20
}
&
\cellcolor
{
blue!2
0
}
\\
\hline
\cellcolor
{
blue!
30
}
&
\cellcolor
{
blue!30
}
&
\cellcolor
{
blue!3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbk2.north)
{$
\mathbi
{
K
}^{
\mathrm
{
T
}}$}
;
...
...
@@ -78,9 +78,9 @@
\node
(mask) at ([xshift=3em,yshift=-2em]tbk2.east)
{
\begin{tabular}
{
|l|l|l|
}
\hline
\cellcolor
{
green!
20
}
&
\cellcolor
{
green!20
}
&
\cellcolor
{
green!2
0
}
\\
\hline
\cellcolor
{
green!
20
}
&
\cellcolor
{
green!20
}
&
\cellcolor
{
green!2
0
}
\\
\hline
\cellcolor
{
green!
20
}
&
\cellcolor
{
green!20
}
&
\cellcolor
{
green!2
0
}
\\
\hline
\cellcolor
{
green!
30
}
&
\cellcolor
{
green!30
}
&
\cellcolor
{
green!3
0
}
\\
\hline
\cellcolor
{
green!
30
}
&
\cellcolor
{
green!30
}
&
\cellcolor
{
green!3
0
}
\\
\hline
\cellcolor
{
green!
30
}
&
\cellcolor
{
green!30
}
&
\cellcolor
{
green!3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]mask.north)
{$
\mathbi
{
Mask
}$}
;
...
...
@@ -93,9 +93,9 @@
\node
(tbv2) at ([xshift=1.2em,yshift=0]mask.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv2.north)
{$
\mathbi
{
V
}$}
;
...
...
@@ -108,9 +108,9 @@
\node
(mid) at ([xshift=1.5em,yshift=0em]sof2.east)
{
\begin{tabular}
{
|l|l|l|
}
\hline
\cellcolor
{
pink!
30
}
&
\cellcolor
{
pink!30
}
&
\cellcolor
{
pink!3
0
}
\\
\hline
\cellcolor
{
pink!
30
}
&
\cellcolor
{
pink!30
}
&
\cellcolor
{
pink!3
0
}
\\
\hline
\cellcolor
{
pink!
30
}
&
\cellcolor
{
pink!30
}
&
\cellcolor
{
pink!3
0
}
\\
\hline
\cellcolor
{
pink!
40
}
&
\cellcolor
{
pink!40
}
&
\cellcolor
{
pink!4
0
}
\\
\hline
\cellcolor
{
pink!
40
}
&
\cellcolor
{
pink!40
}
&
\cellcolor
{
pink!4
0
}
\\
\hline
\cellcolor
{
pink!
40
}
&
\cellcolor
{
pink!40
}
&
\cellcolor
{
pink!4
0
}
\\
\hline
\end{tabular}
}
;
% )
...
...
@@ -126,9 +126,9 @@
\node
(tbv3) at ([xshift=0.5em,yshift=0]bra2.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv3.north)
{$
\mathbi
{
V
}$}
;
...
...
@@ -140,9 +140,9 @@
\node
(result) at ([xshift=2em,yshift=0]eq3.east)
{
\begin{tabular}
{
|l|l|l|
}
\hline
\cellcolor
{
red!
20
}
&
\cellcolor
{
red!20
}
&
\cellcolor
{
red!2
0
}
\\
\hline
\cellcolor
{
red!
20
}&
\cellcolor
{
red!20
}
&
\cellcolor
{
red!2
0
}
\\
\hline
\cellcolor
{
red!
20
}
&
\cellcolor
{
red!20
}
&
\cellcolor
{
red!2
0
}
\\
\hline
\cellcolor
{
red!
30
}
&
\cellcolor
{
red!30
}
&
\cellcolor
{
red!3
0
}
\\
\hline
\cellcolor
{
red!
30
}&
\cellcolor
{
red!30
}
&
\cellcolor
{
red!3
0
}
\\
\hline
\cellcolor
{
red!
30
}
&
\cellcolor
{
red!30
}
&
\cellcolor
{
red!3
0
}
\\
\hline
\end{tabular}
}
;
% x
...
...
@@ -151,9 +151,9 @@
\node
(tbv4) at ([xshift=0.5em,yshift=0]times.east)
{
\begin{tabular}
{
|c|
}
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
2
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\rowcolor
{
orange!
3
0
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv4.north)
{$
\mathbi
{
V
}$}
;
...
...
Chapter12/Figures/figure-self-att-vs-enco-deco-att.tex
查看文件 @
89d4bea0
\begin{tikzpicture}
\node
[rounded corners=1pt,minimum width=11.0em,minimum height=2.0em,fill=pink!
3
0,draw=black]
(p1) at (0,0)
{
\small
{
Self-Attention
}}
;
\node
[rounded corners=1pt,minimum width=11.0em,minimum height=2.0em,fill=pink!
6
0,draw=black]
(p1) at (0,0)
{
\small
{
Self-Attention
}}
;
\node
[anchor=north]
(word1) at ([xshift=0.0em,yshift=-2.0em]p1.south)
{
\small
\mathbi
{
K
}}
;
\node
[anchor=west]
(word2) at ([xshift=2.2em]word1.east)
{
\small
\mathbi
{
V
}}
;
...
...
@@ -19,7 +19,7 @@
\node
[anchor=north]
(caption1) at ([xshift=0.0em,yshift=-9.5em]p1.south)
{
\small
{
(a) Self-Attention的输入
}}
;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node
[anchor=west,rounded corners=1pt,minimum width=14.0em,minimum height=2.0em,fill=pink!
3
0,draw=black]
(p2) at ([xshift=5.0em]p1.east)
{
\small
{
Encoder-Decoder Attention
}}
;
\node
[anchor=west,rounded corners=1pt,minimum width=14.0em,minimum height=2.0em,fill=pink!
5
0,draw=black]
(p2) at ([xshift=5.0em]p1.east)
{
\small
{
Encoder-Decoder Attention
}}
;
\node
[anchor=north]
(word1-2) at ([xshift=0.0em,yshift=-2.0em]p2.south)
{
\small
\mathbi
{
K
}}
;
\node
[anchor=west]
(word2-2) at ([xshift=2.2em]word1-2.east)
{
\small
\mathbi
{
V
}}
;
...
...
Chapter12/Figures/figure-transformer-input-and-position-encoding.tex
查看文件 @
89d4bea0
...
...
@@ -6,8 +6,8 @@
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
outputnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
1
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
5
!white];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
2
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
10
!white];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[Sanode,anchor=west] (sa1) at (0,0)
{
\tiny
{$
\textbf
{
Self
-
Attention
}$}}
;
...
...
Chapter12/Figures/figure-transformer.tex
查看文件 @
89d4bea0
...
...
@@ -2,12 +2,12 @@
\begin{tikzpicture}
\begin{scope}
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
2
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
2
0];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
1
0];
\tikzstyle
{
outputnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
3
0];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
1
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
5
!white];
\tikzstyle
{
Sanode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=orange!
3
0];
\tikzstyle
{
Resnode
}
= [minimum height=1.1em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=yellow!
3
0];
\tikzstyle
{
ffnnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
2
0];
\tikzstyle
{
outputnode
}
= [minimum height=1.4em,minimum width=7em,inner sep=3pt,rounded corners=1.5pt,draw,fill=blue!
4
0];
\tikzstyle
{
inputnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=red!
2
0];
\tikzstyle
{
posnode
}
= [minimum height=1.4em,minimum width=3.5em,inner sep=3pt,rounded corners=1.5pt,draw,fill=black!
10
!white];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[Sanode,anchor=west] (sa1) at (0,0)
{
\tiny
{$
\textbf
{
Self
-
Attention
}$}}
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论