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
043f2b30
Commit
043f2b30
authored
Nov 09, 2020
by
zengxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
10 11
parent
2e5ec1f0
隐藏空白字符变更
内嵌
并排
正在显示
29 个修改的文件
包含
458 行增加
和
209 行删除
+458
-209
Chapter10/Figures/figure-3-base-problom-of-p.tex
+6
-6
Chapter10/Figures/figure-calculation-process-of-context-vector-c.tex
+8
-8
Chapter10/Figures/figure-decoding-process-based-on-greedy-method.tex
+10
-10
Chapter10/Figures/figure-example-of-context-vector-calculation-process.tex
+6
-5
Chapter10/Figures/figure-gru01.tex
+2
-2
Chapter10/Figures/figure-gru02.tex
+2
-2
Chapter10/Figures/figure-gru03.tex
+4
-4
Chapter10/Figures/figure-lstm01.tex
+3
-3
Chapter10/Figures/figure-lstm02.tex
+3
-3
Chapter10/Figures/figure-lstm03.tex
+4
-4
Chapter10/Figures/figure-lstm04.tex
+6
-6
Chapter10/Figures/figure-query-model-corresponding-to-attention-mechanism.tex
+9
-9
Chapter10/Figures/figure-the-whole-of-lstm.tex
+10
-10
Chapter11/Figures/figure-average-pooling.tex
+4
-0
Chapter11/Figures/figure-convolution-kernel.tex
+16
-3
Chapter11/Figures/figure-deep-vs-light.tex
+8
-8
Chapter11/Figures/figure-dimension-transformation.tex
+10
-4
Chapter11/Figures/figure-fairseq-0.tex
+159
-0
Chapter11/Figures/figure-image-convolution.tex
+5
-2
Chapter11/Figures/figure-max-pooling.tex
+4
-0
Chapter11/Figures/figure-padding-and-conv.tex
+12
-4
Chapter11/Figures/figure-padding-method.tex
+8
-0
Chapter11/Figures/figure-single-glu.tex
+9
-0
Chapter11/Figures/figure-standard.tex
+13
-13
Chapter11/Figures/figure-structural-comparison-b.tex
+55
-54
Chapter11/Figures/figure-use-cnn-in-nmt.tex
+5
-3
Chapter11/Figures/figure-use-cnn-in-sentence-classification.tex
+12
-11
Chapter11/chapter11.tex
+12
-11
bibliography.bib
+53
-24
没有找到文件。
Chapter10/Figures/figure-3-base-problom-of-p.tex
查看文件 @
043f2b30
...
...
@@ -15,9 +15,9 @@
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=west]
(eemb
\x
) at ([xshift=0.4
\base
]eemb
\y
.east)
{
\tiny
{$
e
_
x
()
$}}
;
\foreach
\x
in
{
1,2,...,3
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(enc
\x
) at ([yshift=0.3
\base
]eemb
\x
.north)
{}
;
\node
[]
(enclabel1) at (enc1)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_{
m
-
2
}$}}
;
\node
[]
(enclabel2) at (enc2)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_{
m
-
1
}$}}
;
\node
[rnnnode,fill=purple!30!white]
(enclabel3) at (enc3)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_{
m
}$}}
;
\node
[]
(enclabel1) at (enc1)
{
\tiny
{$
\
mathbi
{
h
}_{
m
-
2
}$}}
;
\node
[]
(enclabel2) at (enc2)
{
\tiny
{$
\
mathbi
{
h
}_{
m
-
1
}$}}
;
\node
[rnnnode,fill=purple!30!white]
(enclabel3) at (enc3)
{
\tiny
{$
\
mathbi
{
h
}_{
m
}$}}
;
\node
[wordnode,left=0.4\base of enc1]
(init1)
{$
\cdots
$}
;
\node
[wordnode,left=0.4\base of eemb1]
(init2)
{$
\cdots
$}
;
...
...
@@ -29,7 +29,7 @@
\foreach
\x
in
{
1,2,...,3
}
\node
[rnnnode,minimum height=0.5\base,fill=green!30!white,anchor=south]
(demb
\x
) at ([yshift=
\base
]enc
\x
.north)
{
\tiny
{$
e
_
y
()
$}}
;
\foreach
\x
in
{
1,2,...,3
}
\node
[rnnnode,fill=blue!30!white,anchor=south]
(dec
\x
) at ([yshift=0.3
\base
]demb
\x
.north)
{{
\tiny
{$
\
vectorn
{
\emph
{
s
}
}_
\x
$}}}
;
\node
[rnnnode,fill=blue!30!white,anchor=south]
(dec
\x
) at ([yshift=0.3
\base
]demb
\x
.north)
{{
\tiny
{$
\
mathbi
{
s
}_
\x
$}}}
;
\foreach
\x
in
{
1,2,...,3
}
\node
[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=south]
(softmax
\x
) at ([yshift=0.3
\base
]dec
\x
.north)
{
\tiny
{
Softmax
}}
;
\node
[wordnode,right=0.4\base of demb3]
(end1)
{$
\cdots
$}
;
...
...
@@ -73,7 +73,7 @@
\draw
[-latex']
(enc3.north) .. controls +(north:0.3
\base
) and +(east:
\base
) .. (bridge) .. controls +(west:2.7
\base
) and +(west:0.3
\base
) .. (dec1.west);
{
\node
[anchor=east] (line1) at ([xshift=-3em,yshift=0.5em]softmax1.west)
{
\scriptsize
{
基于RNN的隐层状态
$
\
vectorn
{
\emph
{
s
}
}_
i
$}}
;
\node
[anchor=east] (line1) at ([xshift=-3em,yshift=0.5em]softmax1.west)
{
\scriptsize
{
基于RNN的隐层状态
$
\
mathbi
{
s
}_
i
$}}
;
\node
[anchor=north west] (line2) at ([yshift=0.3em]line1.south west)
{
\scriptsize
{
预测目标词的概率
}}
;
\node
[anchor=north west] (line3) at ([yshift=0.3em]line2.south west)
{
\scriptsize
{
通常,用Softmax函数
}}
;
\node
[anchor=north west] (line4) at ([yshift=0.3em]line3.south west)
{
\scriptsize
{
实现
$
\funp
{
P
}
(
y
_
i|...
)
$}}
;
...
...
@@ -90,7 +90,7 @@
\node
[anchor=west] (line21) at ([xshift=1.3em,yshift=1.5em]enc3.east)
{
\scriptsize
{
源语编码器最后一个
}}
;
\node
[anchor=north west] (line22) at ([yshift=0.3em]line21.south west)
{
\scriptsize
{
循环单元的输出被
}}
;
\node
[anchor=north west] (line23) at ([yshift=0.3em]line22.south west)
{
\scriptsize
{
看作是句子的表示,
}}
;
\node
[anchor=north west] (line24) at ([yshift=0.3em]line23.south west)
{
\scriptsize
{
记为
$
\
vectorn
{
\emph
{
C
}
}$}}
;
\node
[anchor=north west] (line24) at ([yshift=0.3em]line23.south west)
{
\scriptsize
{
记为
$
\
mathbi
{
C
}$}}
;
}
\begin{pgfonlayer}
{
background
}
...
...
Chapter10/Figures/figure-calculation-process-of-context-vector-c.tex
查看文件 @
043f2b30
...
...
@@ -8,17 +8,17 @@
\begin{scope}
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h1) at (0,0)
{
\scriptsize
{$
\
vectorn
{
h
}_
1
$}}
;
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h2) at ([xshift=1em]h1.east)
{
\scriptsize
{$
\
vectorn
{
h
}_
2
$}}
;
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h1) at (0,0)
{
\scriptsize
{$
\
mathbi
{
h
}_
1
$}}
;
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h2) at ([xshift=1em]h1.east)
{
\scriptsize
{$
\
mathbi
{
h
}_
2
$}}
;
\node
[anchor=west,inner sep=0pt,minimum width=3em] (h3) at ([xshift=0.5em]h2.east)
{
\scriptsize
{
...
}}
;
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h4) at ([xshift=0.5em]h3.east)
{
\scriptsize
{$
\
vectorn
{
h
}_
m
$}}
;
\node
[anchor=west,draw,fill=red!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (h4) at ([xshift=0.5em]h3.east)
{
\scriptsize
{$
\
mathbi
{
h
}_
m
$}}
;
\node
[anchor=south,circle,minimum size=1.0em,draw,ublue,thick] (sum) at ([yshift=2em]h2.north east)
{}
;
\draw
[thick,-,ublue] (sum.north) -- (sum.south);
\draw
[thick,-,ublue] (sum.west) -- (sum.east);
\node
[anchor=south,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th1) at ([yshift=2em,xshift=-1em]sum.north west)
{
\scriptsize
{$
\
vectorn
{
s
}_{
j
-
1
}$}}
;
\node
[anchor=west,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th2) at ([xshift=2em]th1.east)
{
\scriptsize
{$
\
vectorn
{
s
}_{
j
}$}}
;
\node
[anchor=south,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th1) at ([yshift=2em,xshift=-1em]sum.north west)
{
\scriptsize
{$
\
mathbi
{
s
}_{
j
-
1
}$}}
;
\node
[anchor=west,draw,fill=green!20!white,inner sep=3pt,minimum width=2em,minimum height=1.2em] (th2) at ([xshift=2em]th1.east)
{
\scriptsize
{$
\
mathbi
{
s
}_{
j
}$}}
;
\draw
[->] (h1.north) .. controls +(north:0.8) and +(west:1) .. (sum.190) node [pos=0.2,left]
{
\scriptsize
{$
\alpha
_{
1
,j
}$}}
;
\draw
[->] (h2.north) .. controls +(north:0.6) and +(220:0.2) .. (sum.220) node [pos=0.2,right]
{
\scriptsize
{$
\alpha
_{
2
,j
}$}}
;
...
...
@@ -27,7 +27,7 @@
\draw
[->] ([xshift=-1.5em]th1.west) -- ([xshift=-0.1em]th1.west);
\draw
[->] ([xshift=0.1em]th1.east) -- ([xshift=-0.1em]th2.west);
\draw
[->] ([xshift=0.1em]th2.east) -- ([xshift=1.5em]th2.east);
\draw
[->] (sum.north) .. controls +(north:0.8) and +(west:0.2) .. ([yshift=-0.4em,xshift=-0.1em]th2.west) node [pos=0.2,right] (ci)
{
\scriptsize
{$
\
vectorn
{
C
}_{
j
}$}}
;
\draw
[->] (sum.north) .. controls +(north:0.8) and +(west:0.2) .. ([yshift=-0.4em,xshift=-0.1em]th2.west) node [pos=0.2,right] (ci)
{
\scriptsize
{$
\
mathbi
{
C
}_{
j
}$}}
;
\node
[anchor=south,inner sep=1pt] (output) at ([yshift=0.8em]th2.north)
{
\scriptsize
{
输出层
}}
;
\draw
[->] ([yshift=0.1em]th2.north) -- ([yshift=-0.1em]output.south);
...
...
@@ -39,11 +39,11 @@
\node
[anchor=north] (enc42) at ([yshift=0.5em]enc4.south)
{
\scriptsize
{
(位置
$
4
$
)
}}
;
{
\node
[anchor=west] (math1) at ([xshift=5em,yshift=1em]th2.east)
{$
\
vectorn
{
C
}_
j
=
\sum
_{
i
}
\alpha
_{
i,j
}
\vectorn
{
h
}_
i
$
\ \ \ \
}
;
\node
[anchor=west] (math1) at ([xshift=5em,yshift=1em]th2.east)
{$
\
mathbi
{
C
}_
j
=
\sum
_{
i
}
\alpha
_{
i,j
}
\mathbi
{
h
}_
i
$
\ \ \ \
}
;
}
{
\node
[anchor=north west] (math2) at ([yshift=-2em,xshift=-0.2em]math1.south west)
{$
\alpha
_{
i,j
}
=
\frac
{
\exp
(
\beta
_{
i,j
}
)
}{
\sum
_{
i'
}
\exp
(
\beta
_{
i',j
}
)
}$}
;
\node
[anchor=north west] (math3) at ([yshift=-0em]math2.south west)
{$
\beta
_{
i,j
}
=
a
(
\
vectorn
{
s
}_{
j
-
1
}
,
\vectorn
{
h
}_
i
)
$}
;
\node
[anchor=north west] (math3) at ([yshift=-0em]math2.south west)
{$
\beta
_{
i,j
}
=
a
(
\
mathbi
{
s
}_{
j
-
1
}
,
\mathbi
{
h
}_
i
)
$}
;
}
\begin{pgfonlayer}
{
background
}
...
...
Chapter10/Figures/figure-decoding-process-based-on-greedy-method.tex
查看文件 @
043f2b30
...
...
@@ -2,9 +2,9 @@
\begin{scope}
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.1em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\node
[rnnnode,anchor=west] (h1) at (0,0)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}}_
1
$}}
;
\node
[rnnnode,anchor=west] (h1) at (0,0)
{
\tiny
{$
\
mathbi
{
\emph
{
h
}}_
1
$}}
;
\node
[anchor=west] (h2) at ([xshift=1em]h1.east)
{
\tiny
{
...
}}
;
\node
[rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}}_
m
$}}
;
\node
[rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east)
{
\tiny
{$
\
mathbi
{
\emph
{
h
}}_
m
$}}
;
\node
[rnnnode,anchor=north,fill=green!20] (e1) at ([yshift=-1em]h1.south)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[anchor=west] (e2) at ([xshift=1em]e1.east)
{
\tiny
{
...
}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
...
...
@@ -19,7 +19,7 @@
\draw
[->] ([xshift=0.1em]h1.east) -- ([xshift=-0.1em]h2.west);
\draw
[->] ([xshift=0.1em]h2.east) -- ([xshift=-0.1em]h3.west);
\draw
[->] ([xshift=-0.8em]h1.west) -- ([xshift=-0.1em]h1.west) node [pos=0,left,inner sep=2pt]
{
\tiny
{
0
}}
;
\node
[anchor=south] (encoder) at ([xshift=-0.2em]h1.north west)
{
\scriptsize
{
\
vectorn
{
编码器
}}}
;
\node
[anchor=south] (encoder) at ([xshift=-0.2em]h1.north west)
{
\scriptsize
{
\
mathbi
{
编码器
}}}
;
{
\node
[rnnnode,anchor=west,fill=green!20] (t1) at ([xshift=3em]h3.east)
{
\tiny
{$
e
_
y
()
$}}
;
...
...
@@ -33,14 +33,14 @@
\node
[anchor=west,inner sep=2pt] (t5) at ([xshift=0.3em]t4.east)
{
\tiny
{
...
}}
;
}
{
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}}_
1
$}}
;
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\tiny
{$
\
mathbi
{
\emph
{
s
}}_
1
$}}
;
}
{
\node
[rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}}_
2
$}}
;
\node
[rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north)
{
\tiny
{$
\
mathbi
{
\emph
{
s
}}_
2
$}}
;
}
{
\node
[rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}}_
3
$}}
;
\node
[rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}}_
4
$}}
;
\node
[rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north)
{
\tiny
{$
\
mathbi
{
\emph
{
s
}}_
3
$}}
;
\node
[rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north)
{
\tiny
{$
\
mathbi
{
\emph
{
s
}}_
4
$}}
;
\node
[anchor=west,inner sep=2pt] (s5) at ([xshift=0.3em]s4.east)
{
\tiny
{
...
}}
;
}
{
...
...
@@ -131,7 +131,7 @@
}
{
\node
[circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c2) at ([yshift=2em]h2.north)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}}_
2
$}}
;
\node
[circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c2) at ([yshift=2em]h2.north)
{
\tiny
{$
\
mathbi
{
\emph
{
C
}}_
2
$}}
;
\node
[anchor=south] (c2label) at (c2.north)
{
\tiny
{
\textbf
{
注意力机制:上下文
}}}
;
\node
[anchor=south] (c2more) at ([yshift=-1.5em]c2.south)
{
\tiny
{
...
}}
;
\draw
[->] (h1.north) .. controls +(north:0.6) and +(250:0.9) .. (c2.250);
...
...
@@ -143,12 +143,12 @@
}
{
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}}_
3
$}}
;
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south)
{
\tiny
{$
\
mathbi
{
\emph
{
C
}}_
3
$}}
;
\draw
[->] ([xshift=-0.7em]c3.west) -- ([xshift=-0.1em]c3.west);
\draw
[->] ([xshift=0.1em]c3.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]s3.west);
}
{
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}}_
4
$}}
;
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south)
{
\tiny
{$
\
mathbi
{
\emph
{
C
}}_
4
$}}
;
\draw
[->] ([xshift=-0.7em]c4.west) -- ([xshift=-0.1em]c4.west);
\draw
[->] ([xshift=0.1em]c4.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]s4.west);
}
...
...
Chapter10/Figures/figure-example-of-context-vector-calculation-process.tex
查看文件 @
043f2b30
...
...
@@ -104,9 +104,9 @@
%\visible<3->
{
% coverage score formula node
\node
[anchor=north west] (formula) at ([xshift=-0.3
\hnode
,yshift=-1.5
\hnode
]attn11.south)
{
\small
{
不同
$
\
vectorn
{
C
}_
j
$
所对应的源语言词的权重是不同的
}}
;
\node
[anchor=north west] (example) at (formula.south west)
{
\footnotesize
{$
\
vectorn
{
C
}_
2
=
0
.
4
\times
\vectorn
{
h
}
(
\textrm
{
“你”
}
)
+
0
.
4
\times
\vectorn
{
h
}
(
\textrm
{
“什么”
}
)
+
$}}
;
\node
[anchor=north west] (example2) at ([yshift=0.4em]example.south west)
{
\footnotesize
{$
\ \ \ \ \ \ \ \
0
\times
\
vectorn
{
h
}
(
\textrm
{
“都”
}
)
+
0
.
1
\times
\vectorn
{
h
}
(
\textrm
{
“ 没”
}
)
+
..
$}}
;
\node
[anchor=north west] (formula) at ([xshift=-0.3
\hnode
,yshift=-1.5
\hnode
]attn11.south)
{
\small
{
不同
$
\
mathbi
{
C
}_
j
$
所对应的源语言词的权重是不同的
}}
;
\node
[anchor=north west] (example) at (formula.south west)
{
\footnotesize
{$
\
mathbi
{
C
}_
2
=
0
.
4
\times
\mathbi
{
h
}
(
\textrm
{
“你”
}
)
+
0
.
4
\times
\mathbi
{
h
}
(
\textrm
{
“什么”
}
)
+
$}}
;
\node
[anchor=north west] (example2) at ([yshift=0.4em]example.south west)
{
\footnotesize
{$
\ \ \ \ \ \ \ \
0
\times
\
mathbi
{
h
}
(
\textrm
{
“都”
}
)
+
0
.
1
\times
\mathbi
{
h
}
(
\textrm
{
“ 没”
}
)
+
..
$}}
;
}
%\visible<3->
...
...
@@ -138,12 +138,12 @@
%\visible<2->
{
\node
[anchor=west]
(sc1) at ([xshift=0.9
\hnode
]attn16.east)
{$
\
vectorn
{
C
}_
1
=
\sum
_{
i
=
1
}^{
8
}
\alpha
_{
i
1
}
\vectorn
{
h
}_{
i
}$}
;
\node
[anchor=west]
(sc1) at ([xshift=0.9
\hnode
]attn16.east)
{$
\
mathbi
{
C
}_
1
=
\sum
_{
i
=
1
}^{
8
}
\alpha
_{
i
1
}
\mathbi
{
h
}_{
i
}$}
;
}
%\visible<3->
{
\node
[anchor=west]
(sc2) at ([xshift=0.9
\hnode
,yshift=0.0
\hnode
]attn26.east)
{$
\
vectorn
{
C
}_
2
=
\sum
_{
i
=
1
}^{
8
}
\alpha
_{
i
2
}
\vectorn
{
h
}_{
i
}$}
;
\node
[anchor=west]
(sc2) at ([xshift=0.9
\hnode
,yshift=0.0
\hnode
]attn26.east)
{$
\
mathbi
{
C
}_
2
=
\sum
_{
i
=
1
}^{
8
}
\alpha
_{
i
2
}
\mathbi
{
h
}_{
i
}$}
;
}
\end{tikzpicture}
\ No newline at end of file
Chapter10/Figures/figure-gru01.tex
查看文件 @
043f2b30
...
...
@@ -78,8 +78,8 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\end{scope}
...
...
Chapter10/Figures/figure-gru02.tex
查看文件 @
043f2b30
...
...
@@ -91,8 +91,8 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\end{scope}
...
...
Chapter10/Figures/figure-gru03.tex
查看文件 @
043f2b30
...
...
@@ -109,11 +109,11 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at (aux71)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
{
\node
[wordnode,anchor=east]
() at (aux87)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at (aux78)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=east]
() at (aux87)
{$
\
mathbi
{
h
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at (aux78)
{$
\
mathbi
{
h
}_{
t
}$}
;
}
\end{scope}
...
...
Chapter10/Figures/figure-lstm01.tex
查看文件 @
043f2b30
...
...
@@ -84,9 +84,9 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
mathbi
{
c
}_{
t
-
1
}$}
;
\end{scope}
...
...
Chapter10/Figures/figure-lstm02.tex
查看文件 @
043f2b30
...
...
@@ -99,9 +99,9 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
mathbi
{
c
}_{
t
-
1
}$}
;
\end{scope}
...
...
Chapter10/Figures/figure-lstm03.tex
查看文件 @
043f2b30
...
...
@@ -113,11 +113,11 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
mathbi
{
c
}_{
t
-
1
}$}
;
{
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
mathbi
{
c
}_{
t
}$}
;
}
\end{scope}
...
...
Chapter10/Figures/figure-lstm04.tex
查看文件 @
043f2b30
...
...
@@ -131,15 +131,15 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
mathbi
{
c
}_{
t
-
1
}$}
;
{
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
mathbi
{
c
}_{
t
}$}
;
}
{
\node
[wordnode,anchor=east]
() at (aux68)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux29)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=east]
() at (aux68)
{$
\
mathbi
{
h
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux29)
{$
\
mathbi
{
h
}_{
t
}$}
;
}
\end{scope}
...
...
Chapter10/Figures/figure-query-model-corresponding-to-attention-mechanism.tex
查看文件 @
043f2b30
...
...
@@ -4,17 +4,17 @@
\tikzstyle
{
rnode
}
= [draw,minimum width=3.5em,minimum height=1.2em]
\node
[rnode,anchor=south west,fill=red!20!white] (value1) at (0,0)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=1em]value1.south east)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=1em]value2.south east)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=1em]value3.south east)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value1) at (0,0)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value2) at ([xshift=1em]value1.south east)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value3) at ([xshift=1em]value2.south east)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=red!20!white] (value4) at ([xshift=1em]value3.south east)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key1) at ([yshift=0.2em]value1.north west)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key2) at ([yshift=0.2em]value2.north west)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key3) at ([yshift=0.2em]value3.north west)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key4) at ([yshift=0.2em]value4.north west)
{
\scriptsize
{$
\
vectorn
{
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key1) at ([yshift=0.2em]value1.north west)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
你
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key2) at ([yshift=0.2em]value2.north west)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
什么
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key3) at ([yshift=0.2em]value3.north west)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
也
}
)
$}}
;
\node
[rnode,anchor=south west,fill=green!20!white] (key4) at ([yshift=0.2em]value4.north west)
{
\scriptsize
{$
\
mathbi
{
h
}
(
\textrm
{
没
}
)
$}}
;
\node
[rnode,anchor=east] (query) at ([xshift=-2em]key1.west)
{
\scriptsize
{$
\
vectorn
{
s
}
(
\textrm
{
you
}
)
$}}
;
\node
[rnode,anchor=east] (query) at ([xshift=-2em]key1.west)
{
\scriptsize
{$
\
mathbi
{
s
}
(
\textrm
{
you
}
)
$}}
;
\node
[anchor=east] (querylabel) at ([xshift=-0.2em]query.west)
{
\scriptsize
{
query
}}
;
\draw
[->] ([yshift=1pt,xshift=6pt]query.north) .. controls +(90:1em) and +(90:1em) .. ([yshift=1pt]key1.north);
...
...
Chapter10/Figures/figure-the-whole-of-lstm.tex
查看文件 @
043f2b30
...
...
@@ -141,15 +141,15 @@
\end{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
vectorn
{
\emph
{
x
}
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\
mathbi
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\
mathbi
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\
mathbi
{
c
}_{
t
-
1
}$}
;
{
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
vectorn
{
\emph
{
c
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\
mathbi
{
c
}_{
t
}$}
;
}
{
\node
[wordnode,anchor=east]
() at (aux68)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux29)
{$
\
vectorn
{
\emph
{
h
}
}_{
t
}$}
;
\node
[wordnode,anchor=east]
() at (aux68)
{$
\
mathbi
{
h
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux29)
{$
\
mathbi
{
h
}_{
t
}$}
;
}
\end{scope}
...
...
@@ -170,19 +170,19 @@
\begin{scope}
{
% forget gate formula
\node
[formulanode,anchor=south east,text width=10em]
() at ([shift=
{
(4
\base
,1.5
\base
)
}
]aux51)
{
遗忘门
\\
$
\
vectorn
{
\emph
{
f
}}_
t
=
\sigma
(
\vectorn
{
\emph
{
W
}}_
f
[
\vectorn
{
\emph
{
h
}}_{
t
-
1
}
,
\vectorn
{
\emph
{
x
}}_
t
]+
\vectorn
{
\emph
{
b
}
}_
f
)
$}
;
\node
[formulanode,anchor=south east,text width=10em]
() at ([shift=
{
(4
\base
,1.5
\base
)
}
]aux51)
{
遗忘门
\\
$
\
mathbi
{
f
}_
t
=
\sigma
(
\mathbi
{
W
}_
f
[
\mathbi
{
h
}_{
t
-
1
}
,
\mathbi
{
x
}_
t
]+
\mathbi
{
b
}_
f
)
$}
;
}
{
% input gate formula
\node
[formulanode,anchor=north east,text width=10em]
() at ([shift=
{
(4
\base
,-1.5
\base
)
}
]aux21)
{
输入门
\\
$
\
vectorn
{
\emph
{
i
}}_
t
=
\sigma
(
\vectorn
{
\emph
{
W
}}_
i
[
\vectorn
{
\emph
{
h
}}_{
t
-
1
}
,
\vectorn
{
\emph
{
x
}}_
t
]+
\vectorn
{
\emph
{
b
}}_
i
)
$
\\
$
\hat
{
\vectorn
{
\emph
{
c
}}}_
t
=
\mathrm
{
tanh
}
(
\vectorn
{
\emph
{
W
}}_
c
[
\vectorn
{
\emph
{
h
}}_{
t
-
1
}
,
\vectorn
{
\emph
{
x
}}_
t
]+
\vectorn
{
\emph
{
b
}
}_
c
)
$}
;
\node
[formulanode,anchor=north east,text width=10em]
() at ([shift=
{
(4
\base
,-1.5
\base
)
}
]aux21)
{
输入门
\\
$
\
mathbi
{
i
}_
t
=
\sigma
(
\mathbi
{
W
}_
i
[
\mathbi
{
h
}_{
t
-
1
}
,
\mathbi
{
x
}_
t
]+
\mathbi
{
b
}_
i
)
$
\\
$
\hat
{
\mathbi
{
c
}}_
t
=
\mathrm
{
tanh
}
(
\mathbi
{
W
}_
c
[
\mathbi
{
h
}_{
t
-
1
}
,
\mathbi
{
x
}_
t
]+
\mathbi
{
b
}_
c
)
$}
;
}
{
% cell update formula
\node
[formulanode,anchor=south west,text width=10em]
() at ([shift=
{
(-4
\base
,1.5
\base
)
}
]aux59)
{
记忆更新
\\
$
\
vectorn
{
\emph
{
c
}}_{
t
}
=
\vectorn
{
\emph
{
f
}}_
t
\cdot
\vectorn
{
\emph
{
c
}}_{
t
-
1
}
+
\vectorn
{
\emph
{
i
}}_
t
\cdot
\hat
{
\vectorn
{
\emph
{
c
}
}}_
t
$}
;
\node
[formulanode,anchor=south west,text width=10em]
() at ([shift=
{
(-4
\base
,1.5
\base
)
}
]aux59)
{
记忆更新
\\
$
\
mathbi
{
c
}_{
t
}
=
\mathbi
{
f
}_
t
\cdot
\mathbi
{
c
}_{
t
-
1
}
+
\mathbi
{
i
}_
t
\cdot
\hat
{
\mathbi
{
c
}}_
t
$}
;
}
{
% output gate formula
\node
[formulanode,anchor=north west,text width=10em]
() at ([shift=
{
(-4
\base
,-1.5
\base
)
}
]aux29)
{
输出门
\\
$
\
vectorn
{
\emph
{
o
}}_
t
=
\sigma
(
\vectorn
{
\emph
{
W
}}_
o
[
\vectorn
{
\emph
{
h
}}_{
t
-
1
}
,
\vectorn
{
\emph
{
x
}}_
t
]+
\vectorn
{
\emph
{
b
}}_
o
)
$
\\
$
\vectorn
{
\emph
{
h
}}_{
t
}
=
\vectorn
{
\emph
{
o
}}_
t
\cdot
\mathrm
{
tanh
}
(
\vectorn
{
\emph
{
c
}
}_{
t
}
)
$}
;
\node
[formulanode,anchor=north west,text width=10em]
() at ([shift=
{
(-4
\base
,-1.5
\base
)
}
]aux29)
{
输出门
\\
$
\
mathbi
{
o
}_
t
=
\sigma
(
\mathbi
{
W
}_
o
[
\mathbi
{
h
}_{
t
-
1
}
,
\mathbi
{
x
}_
t
]+
\mathbi
{
b
}_
o
)
$
\\
$
\mathbi
{
h
}_{
t
}
=
\mathbi
{
o
}_
t
\cdot
\mathrm
{
tanh
}
(
\mathbi
{
c
}_{
t
}
)
$}
;
}
\end{scope}
\end{tikzpicture}
...
...
Chapter11/Figures/figure-average-pooling.tex
查看文件 @
043f2b30
...
...
@@ -28,4 +28,7 @@
\node
[right of = num2,xshift= -0.7cm]
{}
;
\node
[font=\small]
at ([yshift=-0.7cm,xshift=0.3cm]num12.south)
{
输入:4
$
\times
$
4
}
;
\node
[font=\small]
at ([yshift=-1.3cm,xshift=0.3cm]num19.south)
{
输出:2
$
\times
$
2
}
;
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-convolution-kernel.tex
查看文件 @
043f2b30
...
...
@@ -34,8 +34,20 @@
\node
(num8
_
8)[num,below of = num88,xshift= -0.5cm,yshift= -0.5cm]
{
-1
}
;
\node
(num9
_
9)[num,below of = num99,xshift= -0.5cm,yshift= -0.5cm]
{
-1
}
;
%\node[] (sub) at ([xshift=3.5cm,yshift=2cm]num9_9.east) {$q$:卷积核窗口的长度};
%\node[] (sub2) at ([xshift=0cm,yshift=-0.1cm]sub.south) {$k$:卷积核窗口的宽度};
%\node[] (sub3) at ([xshift=-0.2cm,yshift=-0.1cm]sub2.south) {$o$:卷积核深度\qquad \qquad };
\draw
[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick]
([yshift=0.4cm]num1
_
1.west) -- node[att,xshift=-0.5cm]
{
\large
q
}
([yshift=-0.4cm]num3
_
3.west);
\draw
[decorate,decoration={brace,raise=0pt,amplitude=0.3cm},black,thick]
([xshift=-0.4cm]num1.north) -- node[att,yshift=0.5cm]
{
\large
k
}
([xshift=0.4cm]num7.north);
\draw
[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick]
([xshift=0.4cm]num9
_
9.south) -- node[att,xshift=0.4cm,yshift=-0.3cm]
{
\large
o
}
([xshift=0.4cm]num9.south);
\node
[inner sep=2pt,fill=green!5,draw=ugreen,dotted,very thick,align=center]
(sub) at ([xshift=3.8cm,yshift=2cm]num9
_
9.east)
{
\begin{tabular}
{
r l
}
$
q
$
:
&
卷积核窗口的长度
\\
$
k
$
:
&
卷积核窗口的宽度
\\
$
o
$
:
&
卷积核深度
\end{tabular}
}
;
\node
[minimum width = 1.8cm]
(sub) at ([xshift=-5.5cm,yshift=2cm]num9
_
9.east)
{}
;
\draw
[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick]
([yshift=0.4cm]num1
_
1.west) -- node[att,xshift=-0.5cm]
{
\large
$
q
$}
([yshift=-0.4cm]num3
_
3.west);
\draw
[decorate,decoration={brace,raise=0pt,amplitude=0.3cm},black,thick]
([xshift=-0.4cm]num1.north) -- node[att,yshift=0.5cm]
{
\large
$
k
$}
([xshift=0.4cm]num7.north);
\draw
[decorate,decoration={brace,mirror,raise=0pt,amplitude=0.3cm},black,thick]
([xshift=0.4cm]num9
_
9.south) -- node[att,xshift=0.4cm,yshift=-0.3cm]
{
\large
$
o
$}
([xshift=0.4cm]num9.south);
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-deep-vs-light.tex
查看文件 @
043f2b30
...
...
@@ -15,10 +15,10 @@
}
\foreach
\point
in
{
1,2
}{
\draw
[line width=0.
5
pt, ugreen!80, -latex]
(l
\point
_
0.east) -- (r2
_
0.west);
\draw
[line width=0.
5
pt, orange!80, -latex]
(l
\point
_
1.east) -- (r2
_
1.west);
\draw
[line width=0.
5
pt, cyan!80, -latex]
(l
\point
_
2.east) -- (r2
_
2.west);
\draw
[line width=0.
5
pt, gray!80, -latex]
(l
\point
_
3.east) -- (r2
_
3.west);
\draw
[line width=0.
9
pt, ugreen!80, -latex]
(l
\point
_
0.east) -- (r2
_
0.west);
\draw
[line width=0.
9
pt, orange!80, -latex]
(l
\point
_
1.east) -- (r2
_
1.west);
\draw
[line width=0.
9
pt, cyan!80, -latex]
(l
\point
_
2.east) -- (r2
_
2.west);
\draw
[line width=0.
9
pt, gray!80, -latex]
(l
\point
_
3.east) -- (r2
_
3.west);
}
\node
[vuale]
at (-1.5em, 1.9em)
{$
x
_
2
$}
;
...
...
@@ -40,10 +40,10 @@
}
\foreach
\point
in
{
1,2
}{
\draw
[line width=0.
5
pt, orange!80, -latex]
(l
\point
_
0.east) -- (r2
_
0.west);
\draw
[line width=0.
5
pt, cyan!80, -latex]
(l
\point
_
1.east) -- (r2
_
1.west);
\draw
[line width=0.
5
pt, orange!80, -latex]
(l
\point
_
2.east) -- (r2
_
2.west);
\draw
[line width=0.
5
pt, cyan!80, -latex]
(l
\point
_
3.east) -- (r2
_
3.west);
\draw
[line width=0.
9
pt, orange!80, -latex]
(l
\point
_
0.east) -- (r2
_
0.west);
\draw
[line width=0.
9
pt, cyan!80, -latex]
(l
\point
_
1.east) -- (r2
_
1.west);
\draw
[line width=0.
9
pt, orange!80, -latex]
(l
\point
_
2.east) -- (r2
_
2.west);
\draw
[line width=0.
9
pt, cyan!80, -latex]
(l
\point
_
3.east) -- (r2
_
3.west);
}
\node
[vuale]
at (-1.5em, 1.9em)
{$
x
_
2
$}
;
...
...
Chapter11/Figures/figure-dimension-transformation.tex
查看文件 @
043f2b30
...
...
@@ -45,7 +45,8 @@
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=teal,line width=0.1cm]
at (0.6,2.4)
{}
;
\fill
(4,1.5) circle (2pt);
%\fill (4,1.5) circle (2pt);
\node
[] at (4,1.5)
{
*
}
;
\node
[num]
at (5,0.9)
{
0
}
;
\node
[num]
at (5.6,0.9)
{
1
}
;
...
...
@@ -84,7 +85,11 @@
\node
[minimum width = 0.6cm,minimum height = 0.6cm,draw=teal,line width=0.1cm]
at (9,2.4)
{}
;
\draw
(1.5,-1)node
{
\small
{
输入:6
$
\times
$
6
}}
;
\draw
(5.7,-1)node
{
\small
{
卷积核:3
$
\times
$
3
}}
;
\draw
(10,-1)node
{
\small
{
输出:4
$
\times
$
4
}}
;
\node
[]
(in) at (1.5,-1)
{
\small
{
输入:6
$
\times
$
6
}}
;
\node
[]
at (5.7,-1)
{
\small
{
卷积核:3
$
\times
$
3
}}
;
\node
[]
(out) at (10,-1)
{
\small
{
输出:4
$
\times
$
4
}}
;
\node
[font=\footnotesize,dashed,draw=teal,very thick,fill=green!5,align=center]
at ([yshift=3cm,xshift=1.5cm]out.east)
{
*
\ \
:表示
\\
卷积计算
}
;
\node
[]
at ([yshift=-0.3cm,xshift=-2.3cm]in.east)
{
\ \ \ \ \
}
;
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-fairseq-0.tex
0 → 100644
查看文件 @
043f2b30
\definecolor
{
mc
_
1
_
m
}{
RGB
}{
228,236,255
}
\definecolor
{
mc
_
1
}{
RGB
}{
187,214,255
}
\definecolor
{
mc
_
2
_
m
}{
RGB
}{
255,251,217
}
\definecolor
{
mc
_
2
}{
RGB
}{
232,232,198
}
\definecolor
{
mc
_
3
_
m
}{
RGB
}{
255,247,242
}
\definecolor
{
mc
_
3
}{
RGB
}{
247,228,214
}
\definecolor
{
mc
_
4
_
m
}{
RGB
}{
240,241,254
}
\definecolor
{
mc
_
4
}{
RGB
}{
208,211,244
}
\begin{tikzpicture}
[scale=0.8]
\tikzstyle
{
every node
}
=[scale=0.8]
\tikzstyle
{
rec
}
= [thick,fill=red!10,draw,drop shadow,minimum height =1em,minimum width=2em]
\tikzstyle
{
cir
}
= [line width=0.6pt,fill=yellow!20,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=1em,align=center]
\begin{scope}
\foreach
\point
in
{
0,1,2,3,4,5
}
\node
[rec]
(i
_
\point
) at (
\point
, 0)
{}
;
\draw
[thick]
(i
_
0.0) -- (i
_
1.180);
\draw
[thick]
(i
_
1.0) -- (i
_
2.180);
\draw
[thick]
(i
_
2.0) -- (i
_
3.180);
\draw
[thick]
(i
_
3.0) -- (i
_
4.180);
\draw
[thick]
(i
_
4.0) -- (i
_
5.180);
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
0.south)
{$
<
$
p
$
>
$}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
1.south)
{$
<
$
p
$
>
$}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
2.south)
{$
<
$
s
$
>
$}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
3.south)
{
go
}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
4.south)
{
to
}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
5.south)
{
school
}
;
\foreach
\point
in
{
0,1,2
}
\draw
[thick,fill=blue!20]
(5-
\point
,0.4) -- (5-
\point
,1.5) -- (3-
\point
,0.4) -- (5-
\point
,0.4);
\draw
[thick,fill=blue!40]
(2,0.4) -- (2,1.5) -- (0,0.4) -- (2,0.4);
\foreach
\point
in
{
0,1,2,3
}{
\node
[rec]
(h
_
\point
) at (1.9+
\point
, 1.6)
{}
;
\draw
[thick]
(h
_
\point
.90) -- (h
_
\point
.-90);
}
\foreach
\point
in
{
0,1,2,3
}{
\node
[cir]
(c
_
\point
) at (1.7+
\point
, 2.4)
{}
;
\draw
[out=20,in=160,line width=0.6pt]
(c
_
\point
.-135) to (c
_
\point
.45);
\node
[cir]
(x
_
\point
) at (2.1+
\point
, 3)
{}
;
\draw
[line width=0.6pt]
(x
_
\point
.-135) -- (x
_
\point
.45);
\draw
[line width=0.6pt]
(x
_
\point
.-45) -- (x
_
\point
.135);
\draw
[-latex,thick]
([xshift=-0.5em]h
_
\point
.90) -- (c
_
\point
.-90);
\draw
[-latex,thick]
([xshift=0.5em]h
_
\point
.90) -- (x
_
\point
.-90);
\draw
[-latex,out=90,in=-145,thick]
(c
_
\point
.90) to (x
_
\point
.-145);
}
\foreach
\point
in
{
0,1,2,3
}{
\node
[rec]
(q
_
\point
) at (2.5cm+
\point*
2em, 4)
{}
;
\draw
[-latex,thick]
(x
_
\point
.90) -- (q
_
\point
.-90);
}
\node
[cir]
(o
_
1) at (7.55cm, 4)
{}
;
\draw
[line width=0.6pt]
(o
_
1.90) -- (o
_
1.-90);
\draw
[line width=0.6pt]
(o
_
1.0) -- (o
_
1.180);
\draw
[-latex,thick]
(q
_
3.0) -- (o
_
1.180);
\foreach
\point
in
{
0,1,2
}{
\node
[rec,fill=blue!40]
(g
_
\point
_
0) at (5cm+
\point*
2em, 7.5cm)
{}
;
\node
[rec,fill=blue!40]
(g
_
\point
_
1) at (5cm+
\point*
2em, 7.5cm-1em)
{}
;
\node
[rec,fill=blue!40]
(g
_
\point
_
2) at (5cm+
\point*
2em, 7.5cm-2em)
{}
;
\node
[rec,fill=blue!40]
(g
_
\point
_
3) at (5cm+
\point*
2em, 7.5cm-3em)
{}
;
}
\node
[anchor=north, word]
at ([yshift=-0.6em]g
_
1
_
3.south)
{
\textbf
{
Dot products
}}
;
\draw
[-latex, rounded corners=3pt,thick] (q
_
0.90) -- (2.5cm, 7.5cm) -- (g
_
0
_
0.180);
\draw
[-latex, rounded corners=3pt,thick] (q
_
1.90) -- (2.5cm+2em, 7.5cm-1em) -- (g
_
0
_
1.180);
\draw
[-latex, rounded corners=3pt,thick] (q
_
2.90) -- (2.5cm+4em, 7.5cm-2em) -- (g
_
0
_
2.180);
\draw
[-latex, rounded corners=3pt,thick] (q
_
3.90) -- (2.5cm+6em, 6.2cm-2em) -- (2cm+6em, 6.2cm-2em) -- (2cm+6em, 7.5cm-3em) -- (g
_
0
_
3.180);
\node
[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em]
(g
_
0
_
0) at (5cm, 7.5cm)
{}
;
\node
[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em]
(g
_
1
_
1) at (5cm+2em, 7.5cm-1em)
{}
;
\node
[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em]
(g
_
1
_
2) at (5cm+2em, 7.5cm-2em)
{}
;
\node
[thick,draw,fill=yellow!60,minimum height =1em,minimum width=2em]
(g
_
2
_
3) at (5cm+4em, 7.5cm-3em)
{}
;
\foreach
\point
in
{
0,1,2,3
}
\node
[rec]
(i
_
\point
) at (8+
\point
, 0)
{}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
0.south)
{
go
}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
1.south)
{
to
}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
2.south)
{
school
}
;
\node
[anchor=north,word]
at ([yshift=-0.4em]i
_
3.south)
{$
<
$
/s
$
>
$}
;
\foreach
\point
in
{
0,1,2,3
}{
\node
[cir,font=\fontsize{6}{6}\selectfont,inner sep=0.8pt]
(c
_
\point
) at (8.2cm+
\point*
2em,7.5cm-1em*
\point
)
{
\bm
{$
\sum
$}}
;
\node
[rec]
(q
_
\point
) at (8.2cm+
\point*
2em, 5)
{}
;
\node
[rec]
(b
_
\point
) at (8.2cm+
\point*
2em, 4)
{}
;
\draw
[-latex,thick]
(g
_
2
_
\point
.0) -- (c
_
\point
.180);
\draw
[-latex,thick]
(c
_
\point
.-90) -- (q
_
\point
.90);
\draw
[-latex,thick]
(q
_
\point
.-90) -- (b
_
\point
.90);
\draw
[-latex,thick]
(b
_
\point
.-90) -- ([yshift=-3.5cm]b
_
\point
.-90);
}
\foreach
\point
in
{
2,1
}
\draw
[thick,fill=blue!20]
(4.7cm+
\point*
1cm, 11cm) -- (3.9cm+
\point*
1cm, 12cm) -- (5.5cm+
\point*
1cm, 12cm) -- (4.7cm+
\point*
1cm, 11cm);
\draw
[thick,fill=blue!40]
(4.7cm,11cm) -- (3.9cm,12cm) -- (5.5cm,12cm) -- (4.7cm,11cm);
\foreach
\point
in
{
0,1,2
}{
\node
[rec]
(h
_
\point
) at (5cm+
\point*
2em, 8.8cm)
{}
;
\node
[rec]
(w
_
\point
) at (8.6cm+
\point*
2em, 8.8cm)
{}
;
\node
[cir]
(x
_
\point
) at (4.5cm+
\point*
1cm, 9.6cm)
{}
;
\draw
[line width=0.6pt]
(x
_
\point
.-135) -- (x
_
\point
.45);
\draw
[line width=0.6pt]
(x
_
\point
.-45) -- (x
_
\point
.135);
\node
[cir]
(c
_
\point
) at (4.9cm+
\point*
1cm, 10.2cm)
{}
;
\draw
[line width=0.6pt,out=20,in=160]
(c
_
\point
.-135) to (c
_
\point
.45);
\node
[rec]
(f
_
\point
) at (4.7cm+
\point*
1cm, 11cm)
{}
;
\draw
[-,thick]
(f
_
\point
.90) -- (f
_
\point
.-90);
\draw
[-latex,thick]
([xshift=-0.5em]f
_
\point
.-90) -- (x
_
\point
.90);
\draw
[-latex,thick]
([xshift=0.5em]f
_
\point
.-90) -- (c
_
\point
.90);
\draw
[-latex,out=-90,in=45,thick]
(c
_
\point
.-90) to (x
_
\point
.45);
\draw
[-latex,thick]
(x
_
\point
.-45) -- (h
_
\point
.90);
\draw
[-latex,thick]
(h
_
\point
.-90) -- (g
_
\point
_
0.90);
\node
[rec]
(r
_
\point
) at (4.7cm+
\point*
1cm, 12.5cm)
{}
;
}
\node
[anchor=south,word]
(src
_
1) at ([xshift=-2em,yshift=0.4em]r
_
0.north)
{$
<
$
p
$
>
$}
;
\node
[anchor=south,word]
at ([yshift=0.4em]r
_
0.north)
{
去
}
;
\node
[anchor=south,word]
at ([yshift=0.4em]r
_
1.north)
{
上学
}
;
\node
[anchor=south,word]
at ([yshift=0.4em]r
_
2.north)
{$
<
$
s
$
>
$}
;
\node
[anchor=south,word]
(src
_
2) at ([xshift=2em,yshift=0.4em]r
_
2.north)
{$
<
$
p
$
>
$}
;
\node
[anchor=east, word]
(t
_
1) at ([xshift=-3em]r
_
0.west)
{
\textbf
{
Embeddings
}}
;
\node
[anchor=north, word]
(t
_
2) at ([yshift=-1em]t
_
1.south)
{
\textbf
{
Convolutions
}}
;
\node
[anchor=north, word]
(t
_
3) at ([yshift=-2em]t
_
2.south)
{
\textbf
{
Gated
}}
;
\node
[anchor=north, word]
(t
_
4) at ([yshift=-0.06em]t
_
3.south)
{
\textbf
{
Linear
}}
;
\node
[anchor=north, word]
(t
_
5) at ([yshift=-0.06em]t
_
4.south)
{
\textbf
{
Units
}}
;
\node
[anchor=north, word]
(t
_
6) at ([yshift=-3.2em]t
_
5.south)
{
\textbf
{
Attention
}}
;
\node
[cir]
(o
_
2) at (7.95, 8.8cm)
{}
;
\draw
[line width=0.6pt]
(o
_
2.90) -- (o
_
2.-90);
\draw
[line width=0.6pt]
(o
_
2.0) -- (o
_
2.180);
\draw
[-latex,thick]
(h
_
2.0) -- (o
_
2.180);
\node
[cir]
(o
_
3) at (8.6cm+2em, 10cm)
{}
;
\draw
[thick]
(r
_
0.0) -- (r
_
1.180);
\draw
[thick]
(r
_
1.0) -- (r
_
2.180);
\draw
[rounded corners=3pt,thick]
(r
_
2.0) -- (8.6cm+2em, 12.5cm) -- (o
_
3.90);
\draw
[-latex,thick]
(o
_
3.90) -- (o
_
3.-135) -- (w
_
0.90);
\draw
[-latex,thick]
(o
_
3.90) -- (o
_
3.-90) -- (w
_
1.90);
\draw
[-latex,thick]
(o
_
3.90) -- (o
_
3.-45) -- (w
_
2.90);
\node
[single arrow,minimum height=2.4em,fill=blue!30,minimum width=4pt,rotate=-90,draw, fill=blue!20] at (8.6cm+2em, 8cm)
{}
;
\begin{pgfonlayer}
{
background
}
\draw
[line width=2pt,draw=mc
_
1,fill=mc
_
1
_
m,rounded corners=4pt] ([yshift=0em,xshift=5em]t
_
6.north west) -- ([yshift=0em,xshift=6.1cm]t
_
6.north west) -- ([yshift=2.2cm,xshift=6.1cm]t
_
6.north west) -- ([yshift=2.2cm,xshift=9.4cm]t
_
6.north west) -- ([yshift=-4.8cm,xshift=9.4cm]t
_
6.north west) -- ([yshift=-4.8cm,xshift=-1em]t
_
6.north west)-- ([yshift=0em,xshift=-1em]t
_
6.north west) -- ([yshift=0em,xshift=5em]t
_
6.north west);
\node
[draw=ugreen!30,rectangle,inner ysep=5pt,inner xsep=1.2em,rounded corners=4pt,line width=2pt,fill=ugreen!10] [fit = (src
_
1) (src
_
2)(r
_
2) ] (group1)
{}
;
\draw
[line width=2pt,draw=mc_2,rounded corners=4pt,fill=mc_2_m]
(4.2cm, 12.1cm) -- (7.6cm,12.1cm) -- (7.6cm,8.45cm) -- (3.8cm,8.45cm) -- (3.8cm, 12.1cm) -- (4.2cm, 12.1cm);
\draw
[draw=white,fill=mc_2_m]
(1.3cm, 3.3cm) -- (5.4cm,3.3cm) -- (5.4cm,1.3cm) -- (1.3cm,1.3cm) -- (1.3cm, 3.3cm);
\end{pgfonlayer}
\draw
[line width=2pt,draw=mc_2!180,rounded corners=4pt]
(1.6cm, 3.3cm) -- (5.4cm,3.3cm) -- (5.4cm,1.3cm) -- (1.3cm,1.3cm) -- (1.3cm, 3.3cm) -- (1.6cm, 3.3cm);
\end{scope}
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-image-convolution.tex
查看文件 @
043f2b30
...
...
@@ -25,9 +25,12 @@
\node
[data,inner sep=2pt,fill=cyan!40]
at (14.4em,2.4em)
{
19
}
;
\node
[data,inner sep=2pt]
at (16em,2.4em)
{
25
}
;
\node
[font=\footnotesize]
at (1.6em,4.8em)
{
输入
}
;
\node
[font=\footnotesize]
(in)
at (1.6em,4.8em)
{
输入
}
;
\node
[font=\footnotesize]
at (8.8em,4.8em)
{
卷积核
}
;
\node
[font=\footnotesize]
at (15.2em,4.8em)
{
输出
}
;
\node
[font=\footnotesize]
(out) at (15.2em,4.8em)
{
输出
}
;
\node
[font=\footnotesize,dashed,draw=cyan,very thick,fill=cyan!5,align=center]
at ([yshift=-0.3cm,xshift=1.8cm]out.east)
{
*
\ \
:表示
\\
卷积计算
}
;
\node
[]
at ([yshift=-0.3cm,xshift=-2.3cm]in.east)
{
\ \ \ \ \
}
;
\node
at (5.6em, 1.6em)
{
*
}
;
\node
at (12em, 1.6em)
{
=
}
;
...
...
Chapter11/Figures/figure-max-pooling.tex
查看文件 @
043f2b30
...
...
@@ -28,4 +28,7 @@
\node
[right of = num20,xshift= 0.7cm]
{}
;
\node
[font=\small]
at ([yshift=-0.7cm,xshift=0.3cm]num12.south)
{
输入:4
$
\times
$
4
}
;
\node
[font=\small]
at ([yshift=-1.3cm,xshift=0.3cm]num19.south)
{
输出:2
$
\times
$
2
}
;
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-padding-and-conv.tex
查看文件 @
043f2b30
...
...
@@ -77,7 +77,8 @@
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=teal,line width=0.1cm]
at (0,3)
{}
;
\node
[minimum width = 1.8cm,minimum height = 1.8cm,draw=orange!80,line width=0.08cm]
at (0.6,2.4)
{}
;
\fill
(4.55,1.5) circle (2pt);
%\fill (4.55,1.5) circle (2pt);
\node
[] at (4.55,1.5)
{
*
}
;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node
[num]
at (5.5,0.9)
{
0
}
;
...
...
@@ -140,7 +141,13 @@
\node
[minimum width = 0.6cm,minimum height = 0.6cm,draw=teal,line width=0.1cm]
at (8.4,3)
{}
;
\node
[minimum width = 0.6cm,minimum height = 0.6cm,draw=orange!80,line width=0.08cm]
at (9,2.4)
{}
;
\draw
(1.5,-1.5)node
{
\small
{
输入:8
$
\times
$
8(填充后)
}}
;
\draw
(5.7,-1.5)node
{
\small
{
卷积核:3
$
\times
$
3
}}
;
\draw
(10,-1.5)node
{
\small
{
输出:6
$
\times
$
6
}}
;
%\draw (1.5,-1.5)node{\small{输入:8$\times$8(填充后)}};
%\draw (5.7,-1.5)node{\small{卷积核:3$\times$3}};
%\draw (10,-1.5)node{\small{输出:6$\times$6}};
\node
[]
(in) at (1.5,-1.5)
{
\small
{
输入:8
$
\times
$
8(填充后)
}}
;
\node
[]
at (5.7,-1.5)
{
\small
{
卷积核:3
$
\times
$
3
}}
;
\node
[]
(out) at (10,-1.5)
{
\small
{
输出:6
$
\times
$
6
}}
;
\node
[font=\footnotesize,dashed,draw=teal,very thick,fill=green!5,align=center]
at ([yshift=4cm,xshift=1.8cm]out.east)
{
*
\ \
:表示
\\
卷积计算
}
;
\node
[]
at ([yshift=-0.3cm,xshift=-2.3cm]in.east)
{
\ \ \ \ \
}
;
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-padding-method.tex
查看文件 @
043f2b30
...
...
@@ -23,6 +23,13 @@
\draw
[fill=blue!40,draw=blue!40]
([yshift=0.05em]a4.north) -- ([yshift=0.05em]a6.north) -- ([yshift=-0.05em]b4.south) -- ([yshift=0.05em]a4.north);
\draw
[fill=blue!50,draw=blue!50]
([yshift=0.05em]a5.north) -- ([yshift=0.05em]a7.north) -- ([yshift=-0.05em]b5.south) -- ([yshift=0.05em]a5.north);
\node
[inner sep=2pt,word,fill=blue!5,draw=blue!60,dotted,very thick,align=center,font=\scriptsize]
(sub) at ([xshift=2.3cm,yshift=-0.8cm]b5.east)
{
\begin{tabular}
{
r l
}
$
<
$
p
$
>
$
:
&
填充
\\
$
<
$
sos
$
>
$
:
&
表示序列的开始
\\
$
<
$
eos
$
>
$
:
&
表示序列的终止
\end{tabular}
}
;
\node
[]
at ([xshift=-6em]a1.west)
{}
;
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-single-glu.tex
查看文件 @
043f2b30
...
...
@@ -43,6 +43,15 @@
\node
[word]
(w6) at ([yshift=-
\bd
]w5)
{
日子
}
;
\node
[word]
(w7) at ([yshift=-
\bd
]w6)
{
。
}
;
\node
[word]
(w8) at ([yshift=-
\bd
]w7)
{$
<
$
p
$
>
$}
;
\node
[inner sep=2pt,word,fill=green!5,draw=ugreen,dotted,very thick,minimum width=6em,align=center,minimum height=4em]
(sub) at ([xshift=11cm,yshift=-0.1cm]w1.east)
{
\begin{tabular}
{
r l
}
$
<
$
p
$
>
$
:
&
填充
\\
$
\sigma
$
:
&
sigmoid函数
\\
$
\otimes
$
:
&
按位乘运算
\\
*:
&
卷积计算
\end{tabular}
}
;
% $<$p$>$:填充 \\ $\sigma$:sigmoid函数 \\ $\otimes$:按位乘运算 \\ *:卷积计算
\node
[circle, draw, minimum size=0.7em, inner sep=0.5pt,font=\footnotesize,fill=yellow!40]
(c1) at ([yshift=1.2em]b.north)
{$
\sigma
$}
;
\node
[circle, draw, minimum size=0.7em, inner sep=0.5pt,font=\footnotesize,fill=yellow!40]
(c2) at ([xshift=1.5em]b.east)
{}
;
...
...
Chapter11/Figures/figure-standard.tex
查看文件 @
043f2b30
...
...
@@ -17,19 +17,19 @@
}
\foreach
\point
in
{
0,1,2
}{
\draw
[line width=0.5pt, ugreen!80, -latex]
(l1
_
\point
.east) -- (r2
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l1
_
\point
.east) -- (r2
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l1
_
\point
.east) -- (r2
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l2
_
\point
.east) -- (r2
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l2
_
\point
.east) -- (r2
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l2
_
\point
.east) -- (r2
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l2
_
\point
.east) -- (r3
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l2
_
\point
.east) -- (r3
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l2
_
\point
.east) -- (r3
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l3
_
\point
.east) -- (r3
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l3
_
\point
.east) -- (r3
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l3
_
\point
.east) -- (r3
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l1
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r2
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l1
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r2
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l1
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r2
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l2
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r2
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l2
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r2
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l2
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r2
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l2
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r3
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l2
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r3
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l2
_
\point
.east) -- (
[xshift=-0.1em,yshift=-0.1em]
r3
_
2.west);
\draw
[line width=0.5pt, ugreen!80, -latex]
(l3
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r3
_
0.west);
\draw
[line width=0.5pt, orange!80, -latex]
(l3
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r3
_
1.west);
\draw
[line width=0.5pt, cyan!80, -latex]
(l3
_
\point
.east) -- (
[xshift=0em,yshift=0.1em]
r3
_
2.west);
}
\node
[vuale]
at ([xshift=-0.9em]l1
_
1.west)
{$
x
_
3
$}
;
...
...
Chapter11/Figures/figure-structural-comparison-b.tex
查看文件 @
043f2b30
...
...
@@ -52,59 +52,59 @@
\node
(num4
_
9)[num,right of = num4
_
8,xshift = 1.2cm]
{
\textbf
4
}
;
\node
(num4
_
10)[num,right of = num4
_
9,xshift = 1.2cm, fill = blue!40]
{
\textbf
0
}
;
\draw
[->, thick](num1
_
0.north)--(num2
_
1.south);
\draw
[->, thick](num2
_
0.north)--(num3
_
1.south);
\draw
[->, thick](num3
_
0.north)--(num4
_
1.south);
\draw
[->, thick](num1
_
1.north)--(num2
_
2.south);
\draw
[->, thick](num2
_
1.north)--(num3
_
2.south);
\draw
[->, thick](num3
_
1.north)--(num4
_
2.south);
\draw
[->, thick, color = blue!60](num1
_
2.north)--(num2
_
3.south);
\draw
[->, thick](num2
_
2.north)--(num3
_
3.south);
\draw
[->, thick](num3
_
2.north)--(num4
_
3.south);
\draw
[->, thick, color = blue!60](num1
_
3.north)--(num2
_
4.south);
\draw
[->, thick, color = blue!60](num2
_
3.north)--(num3
_
4.south);
\draw
[->, thick](num3
_
3.north)--(num4
_
4.south);
\draw
[->, thick, color = blue!60](num1
_
4.north)--(num2
_
5.south);
\draw
[->, thick, color = blue!60](num2
_
4.north)--(num3
_
5.south);
\draw
[->, thick, color = blue!60](num3
_
4.north)--(num4
_
5.south);
\draw
[->, thick, color = blue!60](num1
_
5.north)--(num2
_
6.south);
\draw
[->, thick, color = blue!60](num2
_
5.north)--(num3
_
6.south);
\draw
[->, thick](num3
_
5.north)--(num4
_
6.south);
\draw
[->, thick, color = blue!60](num1
_
6.north)--(num2
_
7.south);
\draw
[->, thick](num2
_
6.north)--(num3
_
7.south);
\draw
[->, thick](num3
_
6.north)--(num4
_
7.south);
\draw
[->, thick](num1
_
7.north)--(num2
_
8.south);
\draw
[->, thick](num2
_
7.north)--(num3
_
8.south);
\draw
[->, thick](num3
_
7.north)--(num4
_
8.south);
\draw
[->, thick](num1
_
8.north)--(num2
_
9.south);
\draw
[->, thick](num2
_
8.north)--(num3
_
9.south);
\draw
[->, thick](num3
_
8.north)--(num4
_
9.south);
\draw
[->, thick](num1
_
0.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
1.south);
\draw
[->, thick](num2
_
0.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
1.south);
\draw
[->, thick](num3
_
0.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
1.south);
\draw
[->, thick](num1
_
1.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
2.south);
\draw
[->, thick](num2
_
1.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
2.south);
\draw
[->, thick](num3
_
1.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
2.south);
\draw
[->, thick, color = blue!60](num1
_
2.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
3.south);
\draw
[->, thick](num2
_
2.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
3.south);
\draw
[->, thick](num3
_
2.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
3.south);
\draw
[->, thick, color = blue!60](num1
_
3.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
4.south);
\draw
[->, thick, color = blue!60](num2
_
3.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
4.south);
\draw
[->, thick](num3
_
3.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
4.south);
\draw
[->, thick, color = blue!60](num1
_
4.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
5.south);
\draw
[->, thick, color = blue!60](num2
_
4.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
5.south);
\draw
[->, thick, color = blue!60](num3
_
4.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
5.south);
\draw
[->, thick, color = blue!60](num1
_
5.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
6.south);
\draw
[->, thick, color = blue!60](num2
_
5.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
6.south);
\draw
[->, thick](num3
_
5.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
6.south);
\draw
[->, thick, color = blue!60](num1
_
6.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
7.south);
\draw
[->, thick](num2
_
6.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
7.south);
\draw
[->, thick](num3
_
6.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
7.south);
\draw
[->, thick](num1
_
7.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
8.south);
\draw
[->, thick](num2
_
7.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
8.south);
\draw
[->, thick](num3
_
7.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
8.south);
\draw
[->, thick](num1
_
8.north)--(
[xshift=-0.1em,yshift=-0.1em]
num2
_
9.south);
\draw
[->, thick](num2
_
8.north)--(
[xshift=-0.1em,yshift=-0.1em]
num3
_
9.south);
\draw
[->, thick](num3
_
8.north)--(
[xshift=-0.1em,yshift=-0.1em]
num4
_
9.south);
\draw
[->, thick](num1
_
2.north)--(num2
_
1.south);
\draw
[->, thick](num2
_
2.north)--(num3
_
1.south);
\draw
[->, thick](num3
_
2.north)--(num4
_
1.south);
\draw
[->, thick](num1
_
3.north)--(num2
_
2.south);
\draw
[->, thick](num2
_
3.north)--(num3
_
2.south);
\draw
[->, thick](num3
_
3.north)--(num4
_
2.south);
\draw
[->, thick, color = blue!60](num1
_
4.north)--(num2
_
3.south);
\draw
[->, thick](num2
_
4.north)--(num3
_
3.south);
\draw
[->, thick](num3
_
4.north)--(num4
_
3.south);
\draw
[->, thick, color = blue!60](num1
_
5.north)--(num2
_
4.south);
\draw
[->, thick, color = blue!60](num2
_
5.north)--(num3
_
4.south);
\draw
[->, thick](num3
_
5.north)--(num4
_
4.south);
\draw
[->, thick, color = blue!60](num1
_
6.north)--(num2
_
5.south);
\draw
[->, thick, color = blue!60](num2
_
6.north)--(num3
_
5.south);
\draw
[->, thick, color = blue!60](num3
_
6.north)--(num4
_
5.south);
\draw
[->, thick, color = blue!60](num1
_
7.north)--(num2
_
6.south);
\draw
[->, thick, color = blue!60](num2
_
7.north)--(num3
_
6.south);
\draw
[->, thick](num3
_
7.north)--(num4
_
6.south);
\draw
[->, thick, color = blue!60](num1
_
8.north)--(num2
_
7.south);
\draw
[->, thick](num2
_
8.north)--(num3
_
7.south);
\draw
[->, thick](num3
_
8.north)--(num4
_
7.south);
\draw
[->, thick](num1
_
9.north)--(num2
_
8.south);
\draw
[->, thick](num2
_
9.north)--(num3
_
8.south);
\draw
[->, thick](num3
_
9.north)--(num4
_
8.south);
\draw
[->, thick](num1
_
10.north)--(num2
_
9.south);
\draw
[->, thick](num2
_
10.north)--(num3
_
9.south);
\draw
[->, thick](num3
_
10.north)--(num4
_
9.south);
\draw
[->, thick](num1
_
2.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
1.south);
\draw
[->, thick](num2
_
2.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
1.south);
\draw
[->, thick](num3
_
2.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
1.south);
\draw
[->, thick](num1
_
3.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
2.south);
\draw
[->, thick](num2
_
3.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
2.south);
\draw
[->, thick](num3
_
3.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
2.south);
\draw
[->, thick, color = blue!60](num1
_
4.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
3.south);
\draw
[->, thick](num2
_
4.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
3.south);
\draw
[->, thick](num3
_
4.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
3.south);
\draw
[->, thick, color = blue!60](num1
_
5.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
4.south);
\draw
[->, thick, color = blue!60](num2
_
5.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
4.south);
\draw
[->, thick](num3
_
5.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
4.south);
\draw
[->, thick, color = blue!60](num1
_
6.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
5.south);
\draw
[->, thick, color = blue!60](num2
_
6.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
5.south);
\draw
[->, thick, color = blue!60](num3
_
6.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
5.south);
\draw
[->, thick, color = blue!60](num1
_
7.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
6.south);
\draw
[->, thick, color = blue!60](num2
_
7.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
6.south);
\draw
[->, thick](num3
_
7.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
6.south);
\draw
[->, thick, color = blue!60](num1
_
8.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
7.south);
\draw
[->, thick](num2
_
8.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
7.south);
\draw
[->, thick](num3
_
8.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
7.south);
\draw
[->, thick](num1
_
9.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
8.south);
\draw
[->, thick](num2
_
9.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
8.south);
\draw
[->, thick](num3
_
9.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
8.south);
\draw
[->, thick](num1
_
10.north)--(
[xshift=0.1em,yshift=-0.1em]
num2
_
9.south);
\draw
[->, thick](num2
_
10.north)--(
[xshift=0.1em,yshift=-0.1em]
num3
_
9.south);
\draw
[->, thick](num3
_
10.north)--(
[xshift=0.1em,yshift=-0.1em]
num4
_
9.south);
\end{tikzpicture}
\ No newline at end of file
Chapter11/Figures/figure-use-cnn-in-nmt.tex
查看文件 @
043f2b30
%\newlength{\bc}
\setlength
{
\bc
}{
0.4cm
}
\begin{tikzpicture}
\begin{scope}
...
...
@@ -58,8 +59,9 @@
\draw
[-latex]
(c2.east) -- ([xshift=0.2cm, yshift=-0.2cm]c2.east);
%%%%%%%%%%%%%%%%%%%%%
\node
[word]
(sub) at ([xshift=9.5*
\bc
,yshift=3*
\bc
]w1)
{$
O
$
:卷积核大小
}
;
\node
[word]
(sub2) at ([yshift=-0.5*
\bc
]sub.south)
{$
N
$
:卷积核数量
}
;
\node
[word]
(sub) at ([xshift=9.5*
\bc
,yshift=3.5*
\bc
]w1)
{$
O
$
\ \
:输入通道数
}
;
\node
[word]
(sub2) at ([yshift=-0.5*
\bc
]sub.south)
{$
N
$
\ \
:卷积核数量
}
;
\node
[word]
(sub3) at ([xshift=-1.35em,yshift=-0.5*
\bc
]sub2.south)
{$
<
$
p
$
>
$
:填充
}
;
\end{scope}
...
...
Chapter11/Figures/figure-use-cnn-in-sentence-classification.tex
查看文件 @
043f2b30
%\newlength{\bc}
\setlength
{
\bc
}{
0.4cm
}
\begin{tikzpicture}
\begin{scope}
%\tikzstyle{every node}=[scale=0.8]
\tikzstyle
{
line
}
= [dash pattern=on 2pt off 1pt,line width=0.
5
pt]
\tikzstyle
{
line
}
= [dash pattern=on 2pt off 1pt,line width=0.
6
pt]
\tikzstyle
{
cir
}
= [thin,fill=blue!8,draw,circle,minimum size =0.5em,drop shadow=
{
shadow xshift=0.15em, shadow yshift=-0.1em
}
]
\tikzstyle
{
word
}
= [inner sep=0pt, font=
\footnotesize
,minimum height=
\bc
]
\draw
[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+6*
\bc
,0cm+9*
\bc
);
\draw
[fill=blue!8,xshift=0.3cm,yshift=0.5cm,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+6*
\bc
,0cm+9*
\bc
);
\draw
[ugreen!60,step=\bc,xshift=0.3cm,yshift=0.5cm,gray]
(0cm,0cm) grid (0cm+6*
\bc
,0cm+9*
\bc
);
%\draw[line width=0.7pt,xshift=0.3cm,yshift=0.5cm] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw
[red!60,line width=2pt,xshift=0.3cm,yshift=0.5cm]
(0cm,0cm+2*
\bc
) rectangle (0cm+6*
\bc
,0cm+4*
\bc
);
\draw
[thick,fill=blue!8,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+6*
\bc
,0cm+9*
\bc
);
\draw
[thick,fill=blue!8,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+6*
\bc
,0cm+9*
\bc
);
\draw
[step=\bc,gray]
(0cm,0cm) grid (0cm+6*
\bc
,0cm+9*
\bc
);
%\draw[line width=0.7pt] (0cm,0cm) rectangle (0cm+6*\bc,0cm+9*\bc);
\draw
[red!60,line width=2pt]
(0cm,0cm) rectangle (0cm+6*
\bc
,0cm+2*
\bc
);
...
...
@@ -21,31 +22,31 @@
\draw
[red!60,line width=2pt]
(0cm,0cm+7*
\bc
) rectangle (0cm+6*
\bc
,0cm+9*
\bc
);
\draw
[fill=blue!8,xshift=5.0cm,yshift=1.3cm,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+6*
\bc
);
\draw
[fill=blue!8,xshift=5.0cm,yshift=1.3cm,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+6*
\bc
);
\draw
[step=\bc,gray,xshift=5.0cm,yshift=1.3cm]
(0cm,0cm) grid (0cm+1*
\bc
,0cm+6*
\bc
);
%\draw[xshift=5.0cm,yshift=1.3cm,line width=0.7pt] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw
[ugreen!60,line width=2pt,xshift=5.0cm,yshift=1.3cm]
(0cm,0cm+2*
\bc
) rectangle (0cm+1*
\bc
,0cm+3*
\bc
);
\draw
[gray,fill=blue!8](8cm,2.6cm) -- (8.4cm, 2.6cm) -- (9cm,1cm) -- (8.6cm, 1cm) -- (8cm,2.6cm);
\draw
[gray,fill=blue!8
,line width=0.6pt
](8cm,2.6cm) -- (8.4cm, 2.6cm) -- (9cm,1cm) -- (8.6cm, 1cm) -- (8cm,2.6cm);
\draw
[gray](8.15cm,2.2cm) -- (8.55cm,2.2cm);
\draw
[gray](8.3cm,1.8cm) -- (8.7cm,1.8cm);
\draw
[gray](8.45cm,1.4cm) -- (8.85cm,1.4cm);
\draw
[gray,fill=blue!8](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.4cm) -- (11.3cm, 1.4cm) -- (11cm,2.2cm);
\draw
[gray,fill=blue!8
,line width=0.6pt
](11cm,2.2cm) -- (11.4cm, 2.2cm) -- (11.7cm,1.4cm) -- (11.3cm, 1.4cm) -- (11cm,2.2cm);
\draw
[gray](11.15cm,1.8cm) -- (11.55cm,1.8cm);
\draw
[ugreen!60,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bc
,0cm+6*
\bc
) -- (8cm,2.6cm);
\draw
[ugreen!60,line]
([xshift=5.0cm,yshift=1.3cm]0cm+1*
\bc
,0cm) -- (8.15cm,2.2cm);
\draw
[fill=blue!8,xshift=5.2cm,yshift=1.0cm,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+6*
\bc
);
\draw
[fill=blue!8,xshift=5.2cm,yshift=1.0cm,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+6*
\bc
);
\draw
[step=\bc,gray,xshift=5.2cm,yshift=1.0cm]
(0cm,0cm) grid (0cm+1*
\bc
,0cm+6*
\bc
);
%\draw[line width=0.7pt,xshift=5.2cm,yshift=1.0cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+6*\bc);
\draw
[fill=blue!8,xshift=5.4cm,yshift=0.3cm,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+7*
\bc
);
\draw
[fill=blue!8,xshift=5.4cm,yshift=0.3cm,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+7*
\bc
);
\draw
[step=\bc,gray,xshift=5.4cm,yshift=0.3cm]
(0cm,0cm) grid (0cm+1*
\bc
,0cm+7*
\bc
);
%\draw[line width=0.7pt,xshift=5.4cm,yshift=0.3cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw
[fill=blue!8,xshift=5.6cm,yshift=0cm,line width=0.
2
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+7*
\bc
);
\draw
[fill=blue!8,xshift=5.6cm,yshift=0cm,line width=0.
6
pt]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+7*
\bc
);
\draw
[step=\bc,gray,xshift=5.6cm,yshift=0cm]
(0cm,0cm) grid (0cm+1*
\bc
,0cm+7*
\bc
);
%\draw[line width=0.7pt,xshift=5.6cm,yshift=0cm] (0cm,0cm) rectangle (0cm+1*\bc,0cm+7*\bc);
\draw
[red!60,line width=2pt,xshift=5.6cm,yshift=0cm]
(0cm,0cm) rectangle (0cm+1*
\bc
,0cm+1*
\bc
);
...
...
@@ -86,7 +87,7 @@
%\draw [thick] (10cm, -0.3cm) -- (10cm, -0.5cm) -- node[font=\tiny, align=center,yshift=-0.5cm]{Fully connected layer \\ with dropout and \\ softmax output} (11.7cm,-0.5cm) -- (11.7cm, -0.3cm);
\draw
[thick] (0cm, -0.3cm) -- (0cm, -0.5cm) -- node[font=
\tiny
, align=center,yshift=-0.5cm]
{
维度大小为
$
m
\times
k
$
\\
的静态与非静态通道
\\
的句子表示
}
(2.4cm,-0.5cm) -- (2.4cm, -0.3cm);
\draw
[thick] (3.6cm, -0.3cm) -- (3.6cm, -0.5cm) -- node[font=
\tiny
, align=center,yshift=-0.5cm]
{
具有多个不同大小
\\
的卷积核和特征图
\\
的卷积层
}
(6cm,-0.5cm) -- (6cm, -0.3cm);
\draw
[thick] (7.2cm, -0.3cm) -- (7.2cm, -0.5cm) -- node[font=
\tiny
, align=center,yshift=-0.5cm]
{
Max-over-time
\\
pooling
}
(9cm,-0.5cm) -- (9cm, -0.3cm);
\draw
[thick] (7.2cm, -0.3cm) -- (7.2cm, -0.5cm) -- node[font=
\tiny
, align=center,yshift=-0.5cm]
{
最大池化
}
(9cm,-0.5cm) -- (9cm, -0.3cm);
\draw
[thick] (10cm, -0.3cm) -- (10cm, -0.5cm) -- node[font=
\tiny
, align=center,yshift=-0.5cm]
{
带有dropout
\\
和softmax输出
\\
的全连接层
}
(11.7cm,-0.5cm) -- (11.7cm, -0.3cm);
...
...
Chapter11/chapter11.tex
查看文件 @
043f2b30
...
...
@@ -16,6 +16,7 @@
\renewcommand\figurename
{
图
}
%将figure改为图
\renewcommand\tablename
{
表
}
%将figure改为图
\chapterimage
{
fig-NEU-2.jpg
}
% Chapter heading image
\newlength
{
\bc
}
%----------------------------------------------------------------------------------------
% CHAPTER 11
...
...
@@ -175,8 +176,8 @@
\begin{figure}
[htp]
\centering
%\input{./Chapter11/Figures/figure-f }
\subfigure
[
O(n)
]
{
\input
{
./Chapter11/Figures/figure-structural-comparison-a
}}
\subfigure
[
O(n/k)
]
{
\input
{
./Chapter11/Figures/figure-structural-comparison-b
}}
\subfigure
[
$O(n)$
]
{
\input
{
./Chapter11/Figures/figure-structural-comparison-a
}}
\subfigure
[
$O(n/k)$
]
{
\input
{
./Chapter11/Figures/figure-structural-comparison-b
}}
\caption
{
串行及层级结构对比
}
\label
{
fig:11-9
}
\end{figure}
...
...
@@ -234,7 +235,7 @@
% 图12.
\begin{figure}
[htp]
\centering
\input
{
./Chapter11/Figures/figure-fairseq-
1
}
\input
{
./Chapter11/Figures/figure-fairseq-
0
}
\caption
{
ConvS2S结构
}
\label
{
fig:11-12
}
\end{figure}
...
...
@@ -265,7 +266,7 @@
\begin{figure}
[htp]
\centering
\input
{
./Chapter11/Figures/figure-fairseq-2
}
\caption
{
门控卷积网络机制在模型中的位置
}
\caption
{
门控卷积网络机制在模型中的位置
(黄色背景框部分)
}
\label
{
fig:11-13
}
\end{figure}
%----------------------------------------------
...
...
@@ -284,8 +285,8 @@
\parinterval
图
\ref
{
fig:11-14
}
是单层门控卷积网络的基本结构,
$
\mathbi
{
X
}
\in
\mathbb
{
R
}^{
m
\times
d
}$
为单层网络的输入,
$
\mathbi
{
Y
}
\in
\mathbb
{
R
}^{
m
\times
d
}$
为单层网络的输出,网络结构主要包括卷积计算和GLU非线性单元两部分。如图所示,形式上,卷积操作可以分成两部分,分别使用两个卷积核来得到两个卷积结果:
\begin{eqnarray}
\mathbi
{
A
}
=
\mathbi
{
X
}
\cdot
\mathbi
{
W
}
+
\mathbi
{
b
}_
\mathbi
{
W
}
\nonumber
\\
\mathbi
{
B
}
=
\mathbi
{
X
}
\cdot
\mathbi
{
V
}
+
\mathbi
{
b
}_
\mathbi
{
V
}
\ \
\mathbi
{
A
}
=
\mathbi
{
X
}
*
\mathbi
{
W
}
+
\mathbi
{
b
}_
\mathbi
{
W
}
\nonumber
\\
\mathbi
{
B
}
=
\mathbi
{
X
}
*
\mathbi
{
V
}
+
\mathbi
{
b
}_
\mathbi
{
V
}
\ \
\label
{
eq:11-1
}
\end{eqnarray}
...
...
@@ -355,19 +356,19 @@ x_{l+1} = x_l + F (x_l)
\begin{figure}
[htp]
\centering
\input
{
./Chapter11/Figures/figure-fairseq-3
}
\caption
{
多跳自注意力机制在模型中的位置
}
\caption
{
多跳自注意力机制在模型中的位置
(蓝色背景框部分)
}
\label
{
fig:11-16
}
\end{figure}
%----------------------------------------------
\parinterval
注意力机制早在基于循环神经网络的翻译模型中被广泛使用
\upcite
{
bahdanau2014neural
}
,用于避免循环神经网络将源语言序列压缩成一个固定维度的向量表示带来的信息损失。另一方面,注意力同样能够帮助解码端区分源语言中不同位置词对当前解码词的贡献权重,其具体的计算过程如下:
\begin{eqnarray}
\mathbi
{
C
}_
j
=
\sum
_
i
\alpha
_{
i,j
}
\mathbi
{
h
}_
i
\\
\alpha
_{
i,j
}
=
\frac
{
\textrm
{
exp
}
(a (
\mathbi
{
s
}_{
j-1
}
,
\mathbi
{
h
}_
i))
}{
\sum
_{
i'
}
\textrm
{
exp
}
(a(
\mathbi
{
s
}_{
j-1
}
,
\mathbi
{
h
}_{
i'
}
))
}
\mathbi
{
C
}_
j
&
=
&
\sum
_
i
\alpha
_{
i,j
}
\mathbi
{
h
}_
i
\\
\alpha
_{
i,j
}
&
=
&
\frac
{
\textrm
{
exp
}
(a (
\mathbi
{
s
}_{
j-1
}
,
\mathbi
{
h
}_
i))
}{
\sum
_{
i'
}
\textrm
{
exp
}
(a(
\mathbi
{
s
}_{
j-1
}
,
\mathbi
{
h
}_{
i'
}
))
}
\label
{
eq:11-5
}
\end{eqnarray}
\noindent
其中
$
\mathbi
{
h
}_
i
$
表示源语端第
$
i
$
个位置的隐层状态,
$
\mathbi
{
s
}_
j
$
表示目标端第
$
j
$
个位置的隐层状态。给定
$
\mathbi
{
s
}_
j
$
和
$
\mathbi
{
h
}_
i
$
,注意力机制通过函数a(
$
\cdot
$
)计算目标语言表示
$
\mathbi
{
s
}_
j
$
与源语言表示
$
\mathbi
{
h
}_
i
$
之间的注意力权重
$
\alpha
_{
i,j
}$
,通过加权平均得到当前目标端位置所需的上下文表示
$
\mathbi
{
C
}_
j
$
。其中a(
$
\cdot
$
)的具体计算方式在
{
\chapterten
}
\ref
{
sec:10.4.2
}
节
已经详细讨论。
\noindent
其中
$
\mathbi
{
h
}_
i
$
表示源语端第
$
i
$
个位置的隐层状态,
$
\mathbi
{
s
}_
j
$
表示目标端第
$
j
$
个位置的隐层状态。给定
$
\mathbi
{
s
}_
j
$
和
$
\mathbi
{
h
}_
i
$
,注意力机制通过函数a(
$
\cdot
$
)计算目标语言表示
$
\mathbi
{
s
}_
j
$
与源语言表示
$
\mathbi
{
h
}_
i
$
之间的注意力权重
$
\alpha
_{
i,j
}$
,通过加权平均得到当前目标端位置所需的上下文表示
$
\mathbi
{
C
}_
j
$
。其中a(
$
\cdot
$
)的具体计算方式在
{
\chapterten
}
已经详细讨论。
\parinterval
对比基于循环神经网络的机器翻译模型(GNMT)仅在解码端的最底层采用注意力机制,在ConvS2S模型中,解码端的每一层中都分别引入了注意力机制,同时通过残差连接的方式将结果作用于上层网络的计算,因此称之为
{
\small\bfnew
{
多跳注意力
}}
(Multi-step Attention)。 其中ConvS2S模型选取向量乘的方式作为a(
$
\cdot
$
)函数具体的数学描述为:
\begin{eqnarray}
...
...
@@ -407,7 +408,7 @@ x_{l+1} = x_l + F (x_l)
\parinterval
ConvS2S同样有针对性的应用了很多工程方面的调整,主要包括:
\begin{itemize}
\item
ConvS2S使用了
{
\small\bfnew
{
Nesterov加速梯度下降法
}}
(NAG),动量累计的系数设置为0.99,当梯度范数超过0.1时重新进行规范化
\upcite
{
Sutskever2013OnTI
}
;
\item
ConvS2S使用了
{
\small\bfnew
{
Nesterov加速梯度下降法
}}
(N
esterov Accelerated Gradient,N
AG),动量累计的系数设置为0.99,当梯度范数超过0.1时重新进行规范化
\upcite
{
Sutskever2013OnTI
}
;
\item
ConvS2S中设置学习率为0.25,每当模型在校验集上的困惑度不再下降时,便在每轮的训练后将学习率降低一个数量级,直至学习率小于一定的阈值(如0.0004)。
\end{itemize}
...
...
bibliography.bib
查看文件 @
043f2b30
...
...
@@ -4223,15 +4223,7 @@ year = {2012}
year={2020},
publisher={ACM New York, NY, USA}
}
@article{blodgett2020language,
title={Language (Technology) is Power: A Critical Survey of" Bias" in NLP},
author={Su Lin Blodgett and
Solon Barocas and
Hal Daum{\'e} III and
Hanna M. Wallach},
journal={arXiv preprint arXiv:2005.14050},
year={2020}
}
@incollection{nguyen2019understanding,
title={Understanding neural networks via feature visualization: A survey},
author={Anh Nguyen and
...
...
@@ -4300,6 +4292,44 @@ year = {2012}
year={2017}
}
@inproceedings{Bastings2017GraphCE,
title={Graph Convolutional Encoders for Syntax-aware Neural Machine Translation},
author={Jasmijn Bastings and
Ivan Titov and W. Aziz and
Diego Marcheggiani and
K. Sima'an},
publisher={Conference on Empirical Methods in Natural Language Processing},
year={2017}
}
@article{KoncelKedziorski2019TextGF,
title={Text Generation from Knowledge Graphs with Graph Transformers},
author={Rik Koncel-Kedziorski and
Dhanush Bekal and Yi Luan and
Mirella Lapata and
Hannaneh Hajishirzi},
journal={ArXiv},
year={2019},
volume={abs/1904.02342}
}
@article{Kovalerchuk2020SurveyOE,
title={Survey of explainable machine learning with visual and granular methods beyond quasi-explanations},
author={Boris Kovalerchuk and
Muhammad Ahmad and
Ankur Teredesai},
journal={ArXiv},
year={2020},
volume={abs/2009.10221}
}
@article{DoshiVelez2017TowardsAR,
title={Towards A Rigorous Science of Interpretable Machine Learning},
author={Finale Doshi-Velez and
Been Kim},
journal={arXiv: Machine Learning},
year={2017}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% chapter 9------------------------------------------------------
...
...
@@ -4635,21 +4665,6 @@ pages ={157-166},
//publisher = {{AAAI} Press},
year = {2017},
}
@inproceedings{DBLP:journals/corr/abs-1905-09418,
author = {Elena Voita and
David Talbot and
Fedor Moiseev and
Rico Sennrich and
Ivan Titov},
title = {Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy
Lifting, the Rest Can Be Pruned},
publisher = {Proceedings of the 57th Conference of the Association for Computational
Linguistics, {ACL} 2019, Florence, Italy, July 28- August 2, 2019,
Volume 1: Long Papers},
pages = {5797--5808},
//publisher = {Association for Computational Linguistics},
year = {2019},
}
@inproceedings{Xiao2019SharingAW,
author = {Tong Xiao and
Yinqiao Li and
...
...
@@ -6057,6 +6072,20 @@ pages ={157-166},
publisher = {Annual Meeting of the Association for Computational Linguistics},
year = {2019}
}
@article{2015OnGulcehre,
title = {On Using Monolingual Corpora in Neural Machine Translation},
author = { Gulcehre Caglar and
Firat Orhan and
Xu Kelvin and
Cho Kyunghyun and
Barrault Loic and
Lin Huei Chi and
Bougares Fethi and
Schwenk Holger and
Bengio Yoshua },
journal = {Computer Science},
year = {2015},
}
%%%%% chapter 16------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论