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
1ee2e81f
Commit
1ee2e81f
authored
Jan 14, 2021
by
zengxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12
parent
5b84c526
显示空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
150 行增加
和
148 行删除
+150
-148
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
没有找到文件。
Chapter12/Figures/figure-a-combination-of-position-encoding-and-word-encoding.tex
查看文件 @
1ee2e81f
\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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
\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
查看文件 @
1ee2e81f
...
...
@@ -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
查看文件 @
1ee2e81f
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论