Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
Toy-MT-Introduction
概览
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
单韦乔
Toy-MT-Introduction
Commits
08a776fd
Commit
08a776fd
authored
Mar 10, 2020
by
曹润柘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update chapter6 figures
parent
84ae9eba
隐藏空白字符变更
内嵌
并排
正在显示
33 个修改的文件
包含
119 行增加
和
107 行删除
+119
-107
Book/Chapter6/Figures/figure-Automatic-generation-of-ancient-poems-based-on-encoder-decoder-framework.tex
+2
-2
Book/Chapter6/Figures/figure-Automatically-generate-instances-of-couplets.tex
+4
-3
Book/Chapter6/Figures/figure-Beam-search-process.tex
+1
-1
Book/Chapter6/Figures/figure-Comparison-of-the-number-of-padding-in-batch.tex
+2
-2
Book/Chapter6/Figures/figure-Decode-the-word-probability-distribution-at-the-first-position.tex
+1
-1
Book/Chapter6/Figures/figure-Decoding-process-based-on-greedy-method.tex
+2
-2
Book/Chapter6/Figures/figure-Double-layer-RNN.tex
+2
-2
Book/Chapter6/Figures/figure-Example-of-automatic-translation-of-classical-Chinese.tex
+6
-5
Book/Chapter6/Figures/figure-Example-of-context-vector-calculation-process.tex
+2
-2
Book/Chapter6/Figures/figure-GRU01.tex
+5
-4
Book/Chapter6/Figures/figure-GRU02.tex
+6
-5
Book/Chapter6/Figures/figure-GRU03.tex
+4
-3
Book/Chapter6/Figures/figure-LSTM01.tex
+6
-5
Book/Chapter6/Figures/figure-LSTM02.tex
+6
-5
Book/Chapter6/Figures/figure-LSTM03.tex
+6
-5
Book/Chapter6/Figures/figure-LSTM04.tex
+4
-3
Book/Chapter6/Figures/figure-Mask-instance-for-future-positions-in-Transformer.tex
+4
-4
Book/Chapter6/Figures/figure-Matrix-Representation-of-Attention-Weights-Between-Chinese-English-Sentence-Pairs.tex
+2
-2
Book/Chapter6/Figures/figure-Position-of-difference-and-layer-regularization-in-the-model.tex
+2
-2
Book/Chapter6/Figures/figure-Position-of-feedforward-neural-network-in-the-model.tex
+2
-2
Book/Chapter6/Figures/figure-Position-of-self-attention-mechanism-in-the-model.tex
+2
-2
Book/Chapter6/Figures/figure-Structure-of-the-network-during-Transformer-training.tex
+2
-2
Book/Chapter6/Figures/figure-Transformer-input-and-position-encoding.tex
+2
-2
Book/Chapter6/Figures/figure-bi-RNN.tex
+2
-2
Book/Chapter6/Figures/figure-convergence&lr.tex
+10
-9
Book/Chapter6/Figures/figure-decode-of-transformer.tex
+3
-3
Book/Chapter6/Figures/figure-lrate-of-transformer.tex
+2
-2
Book/Chapter6/Figures/figure-process06.tex
+1
-1
Book/Chapter6/Figures/figure-self-att-vs-enco-deco-att.tex
+8
-7
Book/Chapter6/Figures/figure-softmax.tex
+6
-5
Book/Chapter6/Figures/figure-structure-of-GNMT.tex
+3
-3
Book/Chapter6/Figures/figure-the-whole-of-LSTM.tex
+7
-7
Book/Chapter6/Figures/figure-transformer.tex
+2
-2
没有找到文件。
Book/Chapter6/Figures/figure-Automatic-generation-of-ancient-poems-based-on-encoder-decoder-framework.tex
查看文件 @
08a776fd
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
\node
[lnode,anchor=west] (l1) at (0,0)
{
编码器
}
;
\node
[lnode,anchor=west] (l1) at (0,0)
{
编码器
}
;
\node
[lnode,anchor=west,fill=blue!20] (l2) at ([xshift=3em]l1.east)
{
解码器
}
;
\node
[lnode,anchor=west,fill=blue!20] (l2) at ([xshift=3em]l1.east)
{
解码器
}
;
\node
[anchor=north] (inputs) at ([xshift=-1.5em,yshift=-1em]l1.south)
{
Inputs: 五 星 红 旗
}
;
\node
[anchor=north] (inputs) at ([xshift=-1.5em,yshift=-1em]l1.south)
{
Inputs: 五 星 红 旗
}
;
\node
[anchor=south] (outputs) at ([xshift=-3.5em,yshift=2em]l2.north)
{
Outputs:
{
\color
{
red
}
五
}
云深处小蓬莱
\ \
{
\color
{
red
}
星
}
斗阑干次第开
}
;
\node
[anchor=south] (outputs) at ([xshift=-3.5em,yshift=2em]l2.north)
{
Outputs:
{
\color
{
red
}
五
}
云深处小蓬莱
\ \
{
\color
{
red
}
星
}
斗阑干次第开
}
;
\node
[anchor=south] (outputs1) at ([xshift=-1.5em,yshift=1em]l2.north)
{{
\color
{
red
}
红
}
旆壁幢春色里
\ \
{
\color
{
red
}
旗
}
亭鼓吹乐声来
}
;
\node
[anchor=south] (outputs1) at ([xshift=-1.5em,yshift=1em]l2.north)
{{
\color
{
red
}
红
}
旆壁幢春色里
\ \
{
\color
{
red
}
旗
}
亭鼓吹乐声来
}
;
\draw
[->,very thick] ([yshift=-1em]l1.south) -- ([yshift=-0.1em]l1.south);
\draw
[->,very thick] ([yshift=-1em]l1.south) -- ([yshift=-0.1em]l1.south);
\draw
[->,very thick] ([yshift=0.1em]l2.north) -- ([yshift=1em]l2.north);
\draw
[->,very thick] ([yshift=0.1em]l2.north) -- ([yshift=1em]l2.north);
\draw
[->,very thick] ([xshift=0.1em]l1.east) -- ([xshift=-0.1em]l2.west);
\draw
[->,very thick] ([xshift=0.1em]l1.east) -- ([xshift=-0.1em]l2.west);
...
...
Book/Chapter6/Figures/figure-Automatically-generate-instances-of-couplets.tex
查看文件 @
08a776fd
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
\begin{tikzpicture}
\begin{tikzpicture}
\begin{scope}
\begin{scope}
\tikzstyle
{
lnode
}
= [minimum height=2.5em,minimum width=12em,inner sep=3pt,rounded corners=2pt,draw=red!75!black,fill=red!5];
\tikzstyle
{
lnode
}
= [minimum height=2.5em,minimum width=12em,inner sep=3pt,
very thick,
rounded corners=2pt,draw=red!75!black,fill=red!5];
\tikzstyle
{
rnode
}
= [minimum height=2.5em,minimum width=12em,inner sep=3pt,rounded corners=2pt,draw=blue!75!black,fill=blue!5];
\tikzstyle
{
rnode
}
= [minimum height=2.5em,minimum width=12em,inner sep=3pt,
very thick,
rounded corners=2pt,draw=blue!75!black,fill=blue!5];
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\tikzstyle
{
standard
}
= [rounded corners=3pt]
\node
[lnode,anchor=west] (l1) at (0,0)
{
上联:翠竹千支歌盛世
}
;
\node
[lnode,anchor=west] (l1) at (0,0)
{
上联:翠竹千支歌盛世
}
;
...
@@ -22,4 +22,4 @@
...
@@ -22,4 +22,4 @@
\node
[rnode,anchor=west] (l10) at ([xshift=1em]l9.east)
{
下联:春回大地满园红
}
;
\node
[rnode,anchor=west] (l10) at ([xshift=1em]l9.east)
{
下联:春回大地满园红
}
;
\end{scope}
\end{scope}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-Beam-search-process.tex
查看文件 @
08a776fd
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
\node
[anchor=west,inner sep=2pt] (o4) at ([xshift=0.3em]o3.east)
{
\scriptsize
{
...
}}
;
\node
[anchor=west,inner sep=2pt] (o4) at ([xshift=0.3em]o3.east)
{
\scriptsize
{
...
}}
;
}
}
\node
[wnode,anchor=north] (wt1) at ([yshift=-0.8em]t1.south)
{
\scriptsize
{$
<eos>
$}}
;
\node
[wnode,anchor=north] (wt1) at ([yshift=-0.8em]t1.south)
{
\scriptsize
{$
\langle
$
eos
$
\rangle
$}}
;
{
{
\node
[wnode,anchor=north] (wt2) at ([yshift=-0.8em]t2.south)
{
\scriptsize
{
Have
}}
;
\node
[wnode,anchor=north] (wt2) at ([yshift=-0.8em]t2.south)
{
\scriptsize
{
Have
}}
;
...
...
Book/Chapter6/Figures/figure-Comparison-of-the-number-of-padding-in-batch.tex
查看文件 @
08a776fd
...
@@ -25,5 +25,4 @@
...
@@ -25,5 +25,4 @@
\node
[rectangle,inner sep=0.5em,rounded corners=2pt,very thick,dotted,draw=ugreen!80] [fit = (s1) (s3) (p1) (p3)] (box0)
{}
;
\node
[rectangle,inner sep=0.5em,rounded corners=2pt,very thick,dotted,draw=ugreen!80] [fit = (s1) (s3) (p1) (p3)] (box0)
{}
;
\node
[rectangle,inner sep=0.5em,rounded corners=2pt,very thick,dotted,draw=ugreen!80] [fit = (s4) (s6) (p4) (p5)] (box0)
{}
;
\node
[rectangle,inner sep=0.5em,rounded corners=2pt,very thick,dotted,draw=ugreen!80] [fit = (s4) (s6) (p4) (p5)] (box0)
{}
;
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-Decode-the-word-probability-distribution-at-the-first-position.tex
查看文件 @
08a776fd
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\scriptsize
{$
\textbf
{
s
}_
1
$}}
;
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\scriptsize
{$
\textbf
{
s
}_
1
$}}
;
}
}
\node
[wnode,anchor=north] (wt1) at ([yshift=-0.8em]t1.south)
{
\scriptsize
{$
<eos>
$}}
;
\node
[wnode,anchor=north] (wt1) at ([yshift=-0.8em]t1.south)
{
\scriptsize
{$
\langle
$
eos
$
\rangle
$}}
;
{
{
\node
[rnnnode,anchor=south,fill=blue!20] (o1) at ([yshift=1em]s1.north)
{
\scriptsize
{
softmax
}}
;
\node
[rnnnode,anchor=south,fill=blue!20] (o1) at ([yshift=1em]s1.north)
{
\scriptsize
{
softmax
}}
;
...
...
Book/Chapter6/Figures/figure-Decoding-process-based-on-greedy-method.tex
查看文件 @
08a776fd
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]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] (w1) at ([yshift=-0.6em]e1.south)
{
\tiny
{
你
}}
;
\node
[anchor=north,inner sep=2pt] (w2) at ([yshift=-0.8em]e2.south)
{
\tiny
{
...
}}
;
\node
[anchor=north,inner sep=2pt] (w2) at ([yshift=-0.8em]e2.south)
{
\tiny
{
...
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{$
<eos>
$}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{$
\langle
$
eos
$
\rangle
$}}
;
\draw
[->] (w1.north) -- ([yshift=-0.1em]e1.south);
\draw
[->] (w1.north) -- ([yshift=-0.1em]e1.south);
\draw
[->] (w3.north) -- ([yshift=-0.1em]e3.south);
\draw
[->] (w3.north) -- ([yshift=-0.1em]e3.south);
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
\node
[anchor=west,inner sep=2pt] (o5) at ([xshift=0.3em]o4.east)
{
\tiny
{
...
}}
;
\node
[anchor=west,inner sep=2pt] (o5) at ([xshift=0.3em]o4.east)
{
\tiny
{
...
}}
;
}
}
{
{
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{$
<eos>
$}}
;
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{$
\langle
$
eos
$
\rangle
$}}
;
}
}
{
{
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
Have
}}
;
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
Have
}}
;
...
...
Book/Chapter6/Figures/figure-Double-layer-RNN.tex
查看文件 @
08a776fd
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
\node
[wordnode,below=0pt of eemb7]
()
{
怎么
}
;
\node
[wordnode,below=0pt of eemb7]
()
{
怎么
}
;
\node
[wordnode,below=0pt of eemb8]
()
{
走
}
;
\node
[wordnode,below=0pt of eemb8]
()
{
走
}
;
\node
[wordnode,below=0pt of eemb9]
()
{
吗
}
;
\node
[wordnode,below=0pt of eemb9]
()
{
吗
}
;
\node
[wordnode,below=0pt of eemb10]
()
{
EOS
}
;
\node
[wordnode,below=0pt of eemb10]
()
{
$
\langle
$
eos
$
\rangle
$
}
;
% RNN Decoder
% RNN Decoder
\foreach
\x
in
{
1,2,...,10
}
\foreach
\x
in
{
1,2,...,10
}
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Station
}
;
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Station
}
;
\ExtractX
{$
(
softmax
10
.north
)
$}
\ExtractX
{$
(
softmax
10
.north
)
$}
\ExtractY
{$
(
decwordout.base
)
$}
\ExtractY
{$
(
decwordout.base
)
$}
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
EOS
}
;
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
$
\langle
$
eos
$
\rangle
$
}
;
% Connections
% Connections
\draw
[-latex']
(init1.east) to (enc11.west);
\draw
[-latex']
(init1.east) to (enc11.west);
...
...
Book/Chapter6/Figures/figure-Example-of-automatic-translation-of-classical-Chinese.tex
查看文件 @
08a776fd
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
\begin{frame}
{}
\begin{frame}
{}
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=red!5!white,colframe=red!75!black
,boxrule=1pt
]
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=red!5!white,colframe=red!75!black]
{
{
\small
{
古文:侍卫步军都指挥使、彰信节度使李继勋营于寿州城南,唐刘仁赡伺继勋无备,出兵击之,杀士卒数百人,焚其攻具。
}
\small
{
古文:侍卫步军都指挥使、彰信节度使李继勋营于寿州城南,唐刘仁赡伺继勋无备,出兵击之,杀士卒数百人,焚其攻具。
}
}
}
\end{tcolorbox}
\end{tcolorbox}
\vspace
{
-0.4em
}
\vspace
{
-0.4em
}
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=blue!5!white,colframe=blue!75!black
,boxrule=1pt
]
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=blue!5!white,colframe=blue!75!black]
{
{
\small
{
现代文:侍卫步军都指挥使、彰信节度使李继勋在寿州城南扎营,唐刘仁赡窥伺李继勋没有防备,出兵攻打他,杀死士兵几百人,烧毁李继勋的攻城器
}
\small
{
现代文:侍卫步军都指挥使、彰信节度使李继勋在寿州城南扎营,唐刘仁赡窥伺李继勋没有防备,出兵攻打他,杀死士兵几百人,烧毁李继勋的攻城器
}
}
}
...
@@ -17,13 +17,13 @@
...
@@ -17,13 +17,13 @@
\vspace
{
0.2em
}
\vspace
{
0.2em
}
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=red!5!white,colframe=red!75!black
,boxrule=1pt
]
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=red!5!white,colframe=red!75!black]
{
{
\small
{
古文:其后人稍稍识之,多延至其家,使为弟子论学。
}
\small
{
古文:其后人稍稍识之,多延至其家,使为弟子论学。
}
}
}
\end{tcolorbox}
\end{tcolorbox}
\vspace
{
-0.4em
}
\vspace
{
-0.4em
}
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=blue!5!white,colframe=blue!75!black
,boxrule=1pt
]
\begin{tcolorbox}
[size=normal,left=2mm,right=1mm,colback=blue!5!white,colframe=blue!75!black]
{
{
\small
{
现代文:后来的人渐渐认识他,多把他请到家里,让他为弟子讲授学问。
}
\small
{
现代文:后来的人渐渐认识他,多把他请到家里,让他为弟子讲授学问。
}
}
}
...
@@ -32,4 +32,4 @@
...
@@ -32,4 +32,4 @@
\vspace
{
-0.8em
}
\vspace
{
-0.8em
}
\end{frame}
\end{frame}
\ No newline at end of file
Book/Chapter6/Figures/figure-Example-of-context-vector-calculation-process.tex
查看文件 @
08a776fd
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
\node
[srcnode]
(src3) at ([xshift=0.5
\hnode
]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src3) at ([xshift=0.5
\hnode
]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5
\hnode
]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5
\hnode
]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5
\hnode
]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5
\hnode
]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5
\hnode
]src5.south west)
{
\scriptsize
{
EOS
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5
\hnode
]src5.south west)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
% target
% target
\node
[tgtnode]
(tgt1) at (-6.0*0.5*
\hnode
,-1.05*
\hnode
+7.5*0.5*
\hnode
)
{
\scriptsize
{
你
}}
;
\node
[tgtnode]
(tgt1) at (-6.0*0.5*
\hnode
,-1.05*
\hnode
+7.5*0.5*
\hnode
)
{
\scriptsize
{
你
}}
;
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
\node
[tgtnode]
(tgt5) at ([yshift=-0.5
\hnode
]tgt4.north east)
{
\scriptsize
{
学
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.5
\hnode
]tgt4.north east)
{
\scriptsize
{
学
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5
\hnode
]tgt5.north east)
{
\scriptsize
{
到
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5
\hnode
]tgt5.north east)
{
\scriptsize
{
到
}}
;
\node
[tgtnode]
(tgt7) at ([yshift=-0.5
\hnode
]tgt6.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt7) at ([yshift=-0.5
\hnode
]tgt6.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt8) at ([yshift=-0.5
\hnode
]tgt7.north east)
{
\scriptsize
{
EOS
}}
;
\node
[tgtnode]
(tgt8) at ([yshift=-0.5
\hnode
]tgt7.north east)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
\end{scope}
\end{scope}
...
...
Book/Chapter6/Figures/figure-GRU01.tex
查看文件 @
08a776fd
...
@@ -74,20 +74,20 @@
...
@@ -74,20 +74,20 @@
\draw
[emph]
(aux71) -| (aux32) -| (aux44);
\draw
[emph]
(aux71) -| (aux32) -| (aux44);
\node
[opnode,circle,draw=red,thick]
() at (aux44)
{$
\sigma
$}
;
\node
[opnode,circle,draw=red,thick]
() at (aux44)
{$
\sigma
$}
;
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at (aux71)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at (aux71)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\end{scope}
\end{scope}
\node
[]
(tanh) at (aux46)
{}
;
\node
[]
(tanh) at (aux46)
{}
;
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-GRU02.tex
查看文件 @
08a776fd
...
@@ -87,20 +87,20 @@
...
@@ -87,20 +87,20 @@
\node
[opnode,circle,draw=red,thick]
() at (aux45)
{$
\sigma
$}
;
\node
[opnode,circle,draw=red,thick]
() at (aux45)
{$
\sigma
$}
;
\node
[opnode,rectangle,rounded corners=2pt,inner sep=2pt,font=\tiny,draw=red,thick]
() at (aux65)
{$
1
-
$}
;
\node
[opnode,rectangle,rounded corners=2pt,inner sep=2pt,font=\tiny,draw=red,thick]
() at (aux65)
{$
1
-
$}
;
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at (aux71)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at (aux71)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\end{scope}
\end{scope}
\node
[]
(tanh) at (aux46)
{}
;
\node
[]
(tanh) at (aux46)
{}
;
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-GRU03.tex
查看文件 @
08a776fd
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
\node
[opnode,circle,draw=red,thick]
() at (aux75)
{
X
}
;
\node
[opnode,circle,draw=red,thick]
() at (aux75)
{
X
}
;
\node
[opnode,circle,draw=red,thick]
() at (aux76)
{
\textbf
{
+
}}
;
\node
[opnode,circle,draw=red,thick]
() at (aux76)
{
\textbf
{
+
}}
;
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
...
@@ -118,8 +118,8 @@
...
@@ -118,8 +118,8 @@
\end{scope}
\end{scope}
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=6pt,fit=(aux22) (aux76) (z76) (tanh)]
(GRU)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-LSTM01.tex
查看文件 @
08a776fd
...
@@ -80,21 +80,21 @@
...
@@ -80,21 +80,21 @@
\draw
[-latex,emph]
(aux12) -- (aux22) -- (aux23) -- (f53);
\draw
[-latex,emph]
(aux12) -- (aux22) -- (aux23) -- (f53);
\node
[opnode,circle,draw=red,thick]
() at (aux33)
{$
\sigma
$}
;
\node
[opnode,circle,draw=red,thick]
() at (aux33)
{$
\sigma
$}
;
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\mathbf
{
c
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\mathbf
{
c
}_{
t
-
1
}$}
;
\end{scope}
\end{scope}
\node
[ ]
(o27) at (aux27)
{
}
;
\node
[ ]
(o27) at (aux27)
{
}
;
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-LSTM02.tex
查看文件 @
08a776fd
...
@@ -102,14 +102,14 @@
...
@@ -102,14 +102,14 @@
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux21)
{$
\mathbf
{
h
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=west]
() at (aux12)
{$
\mathbf
{
x
}_
t
$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\mathbf
{
c
}_{
t
-
1
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=0.5
\base
]aux51)
{$
\mathbf
{
c
}_{
t
-
1
}$}
;
\end{scope}
\end{scope}
\node
[ ]
(o27) at (aux27)
{
}
;
\node
[ ]
(o27) at (aux27)
{
}
;
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-LSTM03.tex
查看文件 @
08a776fd
...
@@ -109,7 +109,7 @@
...
@@ -109,7 +109,7 @@
\node
[opnode,circle,draw=red,thick]
(f53) at (aux53)
{
X
}
;
\node
[opnode,circle,draw=red,thick]
(f53) at (aux53)
{
X
}
;
\node
[opnode,circle,draw=red,thick]
(u55) at (aux55)
{
\textbf
{
+
}}
;
\node
[opnode,circle,draw=red,thick]
(u55) at (aux55)
{
\textbf
{
+
}}
;
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
...
@@ -119,14 +119,14 @@
...
@@ -119,14 +119,14 @@
{
{
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\mathbf
{
c
}_{
t
}$}
;
\node
[wordnode,anchor=south]
() at ([xshift=-0.5
\base
]aux59)
{$
\mathbf
{
c
}_{
t
}$}
;
}
}
\end{scope}
\end{scope}
\node
[ ]
(o27) at (aux27)
{
}
;
\node
[ ]
(o27) at (aux27)
{
}
;
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-LSTM04.tex
查看文件 @
08a776fd
...
@@ -127,7 +127,7 @@
...
@@ -127,7 +127,7 @@
\draw
[-latex,emph]
(o27) -- (aux29);
\draw
[-latex,emph]
(o27) -- (aux29);
\draw
[-latex,emph]
(o27) -| (aux68);
\draw
[-latex,emph]
(o27) -| (aux68);
}
}
\end{scope}
\end{scope}
\begin{scope}
\begin{scope}
...
@@ -144,8 +144,8 @@
...
@@ -144,8 +144,8 @@
\end{scope}
\end{scope}
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-Mask-instance-for-future-positions-in-Transformer.tex
查看文件 @
08a776fd
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
\node
[srcnode]
(src3) at ([xshift=0.5cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src3) at ([xshift=0.5cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5cm]src5.south west)
{
\scriptsize
{
EOS
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5cm]src5.south west)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
% target
% target
\node
[tgtnode]
(tgt1) at (-6.0*0.5*1.0cm,-1.05*1.0cm+5.5*0.5*1.0cm)
{
\scriptsize
{
Have
}}
;
\node
[tgtnode]
(tgt1) at (-6.0*0.5*1.0cm,-1.05*1.0cm+5.5*0.5*1.0cm)
{
\scriptsize
{
Have
}}
;
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
\node
[tgtnode]
(tgt3) at ([yshift=-0.5cm]tgt2.north east)
{
\scriptsize
{
learned
}}
;
\node
[tgtnode]
(tgt3) at ([yshift=-0.5cm]tgt2.north east)
{
\scriptsize
{
learned
}}
;
\node
[tgtnode]
(tgt4) at ([yshift=-0.5cm]tgt3.north east)
{
\scriptsize
{
nothing
}}
;
\node
[tgtnode]
(tgt4) at ([yshift=-0.5cm]tgt3.north east)
{
\scriptsize
{
nothing
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.5cm]tgt4.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.5cm]tgt4.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5cm]tgt5.north east)
{
\scriptsize
{
EOS
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5cm]tgt5.north east)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
{
{
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
\node
[srcnode]
(src3) at ([xshift=0.5cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src3) at ([xshift=0.5cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src4) at ([xshift=0.5cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src5) at ([xshift=0.5cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5cm]src5.south west)
{
\scriptsize
{
EOS
}}
;
\node
[srcnode]
(src6) at ([xshift=0.5cm]src5.south west)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
% target
% target
\node
[tgtnode]
(tgt1) at (5.4*0.5*1.0cm,-1.05*1.0cm+5.5*0.5*1.0cm)
{
\scriptsize
{
Have
}}
;
\node
[tgtnode]
(tgt1) at (5.4*0.5*1.0cm,-1.05*1.0cm+5.5*0.5*1.0cm)
{
\scriptsize
{
Have
}}
;
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
\node
[tgtnode]
(tgt3) at ([yshift=-0.5cm]tgt2.north east)
{
\scriptsize
{
learned
}}
;
\node
[tgtnode]
(tgt3) at ([yshift=-0.5cm]tgt2.north east)
{
\scriptsize
{
learned
}}
;
\node
[tgtnode]
(tgt4) at ([yshift=-0.5cm]tgt3.north east)
{
\scriptsize
{
nothing
}}
;
\node
[tgtnode]
(tgt4) at ([yshift=-0.5cm]tgt3.north east)
{
\scriptsize
{
nothing
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.5cm]tgt4.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.5cm]tgt4.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5cm]tgt5.north east)
{
\scriptsize
{
EOS
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.5cm]tgt5.north east)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
}
}
...
...
Book/Chapter6/Figures/figure-Matrix-Representation-of-Attention-Weights-Between-Chinese-English-Sentence-Pairs.tex
查看文件 @
08a776fd
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
\node
[srcnode]
(src3) at ([xshift=0.6cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src3) at ([xshift=0.6cm]src2.south west)
{
\scriptsize
{
learned
}}
;
\node
[srcnode]
(src4) at ([xshift=0.6cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src4) at ([xshift=0.6cm]src3.south west)
{
\scriptsize
{
nothing
}}
;
\node
[srcnode]
(src5) at ([xshift=0.6cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src5) at ([xshift=0.6cm]src4.south west)
{
\scriptsize
{
?
}}
;
\node
[srcnode]
(src6) at ([xshift=0.6cm]src5.south west)
{
\scriptsize
{
EOS
}}
;
\node
[srcnode]
(src6) at ([xshift=0.6cm]src5.south west)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
% target
% target
\node
[tgtnode]
(tgt1) at (-6.0*0.5*1.2cm,-1.05*1.2cm+7.5*0.5*1.2cm)
{
\scriptsize
{
你
}}
;
\node
[tgtnode]
(tgt1) at (-6.0*0.5*1.2cm,-1.05*1.2cm+7.5*0.5*1.2cm)
{
\scriptsize
{
你
}}
;
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
\node
[tgtnode]
(tgt5) at ([yshift=-0.6cm]tgt4.north east)
{
\scriptsize
{
学
}}
;
\node
[tgtnode]
(tgt5) at ([yshift=-0.6cm]tgt4.north east)
{
\scriptsize
{
学
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.6cm]tgt5.north east)
{
\scriptsize
{
到
}}
;
\node
[tgtnode]
(tgt6) at ([yshift=-0.6cm]tgt5.north east)
{
\scriptsize
{
到
}}
;
\node
[tgtnode]
(tgt7) at ([yshift=-0.6cm]tgt6.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt7) at ([yshift=-0.6cm]tgt6.north east)
{
\scriptsize
{
?
}}
;
\node
[tgtnode]
(tgt8) at ([yshift=-0.6cm]tgt7.north east)
{
\scriptsize
{
EOS
}}
;
\node
[tgtnode]
(tgt8) at ([yshift=-0.6cm]tgt7.north east)
{
\scriptsize
{
$
\langle
$
eos
$
\rangle
$
}}
;
\end{scope}
\end{scope}
...
...
Book/Chapter6/Figures/figure-Position-of-difference-and-layer-regularization-in-the-model.tex
查看文件 @
08a776fd
...
@@ -38,9 +38,9 @@
...
@@ -38,9 +38,9 @@
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
SOS
$
>
$
I am fine
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
sos
$
>
$
I am fine
}$}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
EOS
$
>
$
}$}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
eos
$
>
$
}$}}
;
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (res3.north) -- (ed1.south);
\draw
[->] (res3.north) -- (ed1.south);
...
...
Book/Chapter6/Figures/figure-Position-of-feedforward-neural-network-in-the-model.tex
查看文件 @
08a776fd
...
@@ -36,9 +36,9 @@
...
@@ -36,9 +36,9 @@
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
SOS
$
>
$
I am fine
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
sos
$
>
$
I am fine
}$}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
EOS
$
>
$
}$}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
eos
$
>
$
}$}}
;
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (res3.north) -- (ed1.south);
\draw
[->] (res3.north) -- (ed1.south);
...
...
Book/Chapter6/Figures/figure-Position-of-self-attention-mechanism-in-the-model.tex
查看文件 @
08a776fd
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
SOS
$
>
$
I am fine
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
sos
$
>
$
I am fine
}$}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
EOS
$
>
$
}$}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
eos
$
>
$
}$}}
;
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (res3.north) -- (ed1.south);
\draw
[->] (res3.north) -- (ed1.south);
...
...
Book/Chapter6/Figures/figure-Structure-of-the-network-during-Transformer-training.tex
查看文件 @
08a776fd
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]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] (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] (w2) at ([yshift=-0.6em]e2.south)
{
\tiny
{
好
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{
<eos>
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{
$
\langle
$
eos
$
\rangle
$
}}
;
\node
[anchor=south] (dot1) at ([xshift=0.4em,yshift=-0.7em]h1.south)
{
\tiny
{
...
}}
;
\node
[anchor=south] (dot1) at ([xshift=0.4em,yshift=-0.7em]h1.south)
{
\tiny
{
...
}}
;
\node
[anchor=south] (dot2) at ([xshift=-0.4em,yshift=-0.7em]h3.south)
{
\tiny
{
...
}}
;
\node
[anchor=south] (dot2) at ([xshift=-0.4em,yshift=-0.7em]h3.south)
{
\tiny
{
...
}}
;
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
\node
[anchor=south,fill=black!5!white,minimum height=1.1em,minimum width=13em,inner sep=2pt,rounded corners=1pt,draw] (loss) at ([xshift=1.8em,yshift=1em]o2.north)
{
\scriptsize
{
\textbf
{
Cross Entropy Loss
}}}
;
\node
[anchor=south,fill=black!5!white,minimum height=1.1em,minimum width=13em,inner sep=2pt,rounded corners=1pt,draw] (loss) at ([xshift=1.8em,yshift=1em]o2.north)
{
\scriptsize
{
\textbf
{
Cross Entropy Loss
}}}
;
}
}
{
{
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{
<eos>
}}
;
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{
$
\langle
$
eos
$
\rangle
$
}}
;
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
How
}}
;
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
How
}}
;
\node
[anchor=north,inner sep=2pt] (wt3) at ([yshift=-0.8em]t3.south)
{
\tiny
{
are
}}
;
\node
[anchor=north,inner sep=2pt] (wt3) at ([yshift=-0.8em]t3.south)
{
\tiny
{
are
}}
;
\node
[anchor=north,inner sep=2pt] (wt4) at ([yshift=-0.8em]t4.south)
{
\tiny
{
you
}}
;
\node
[anchor=north,inner sep=2pt] (wt4) at ([yshift=-0.8em]t4.south)
{
\tiny
{
you
}}
;
...
...
Book/Chapter6/Figures/figure-Transformer-input-and-position-encoding.tex
查看文件 @
08a776fd
...
@@ -36,9 +36,9 @@
...
@@ -36,9 +36,9 @@
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
SOS
$
>
$
I am fine
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
sos
$
>
$
I am fine
}$}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
EOS
$
>
$
}$}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
eos
$
>
$
}$}}
;
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (res3.north) -- (ed1.south);
\draw
[->] (res3.north) -- (ed1.south);
...
...
Book/Chapter6/Figures/figure-bi-RNN.tex
查看文件 @
08a776fd
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
\node
[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=south]
(softmax
\x
) at ([yshift=0.5
\base
]dec
\x
.north)
{}
;
\node
[rnnnode,minimum height=0.5\base,fill=red!30!white,anchor=south]
(softmax
\x
) at ([yshift=0.5
\base
]dec
\x
.north)
{}
;
% Decoder input words
% Decoder input words
\node
[wordnode,below=0pt of demb1]
(decwordin)
{
EOS
}
;
\node
[wordnode,below=0pt of demb1]
(decwordin)
{
$
\langle
$
eos
$
\rangle
$
}
;
\ExtractX
{$
(
demb
2
.south
)
$}
\ExtractX
{$
(
demb
2
.south
)
$}
\ExtractY
{$
(
decwordin.base
)
$}
\ExtractY
{$
(
decwordin.base
)
$}
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Do
}
;
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Do
}
;
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Station
}
;
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
Station
}
;
\ExtractX
{$
(
softmax
10
.north
)
$}
\ExtractX
{$
(
softmax
10
.north
)
$}
\ExtractY
{$
(
decwordout.base
)
$}
\ExtractY
{$
(
decwordout.base
)
$}
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
EOS
}
;
\node
[wordnode,anchor=base]
() at (
\XCoord
,
\YCoord
)
{
$
\langle
$
eos
$
\rangle
$
}
;
% Connections
% Connections
\draw
[-latex']
(init.east) to (enc1.west);
\draw
[-latex']
(init.east) to (enc1.west);
...
...
Book/Chapter6/Figures/figure-convergence&lr.tex
查看文件 @
08a776fd
\definecolor
{
ublue
}{
rgb
}{
0.152,0.250,0.545
}
\definecolor
{
ublue
}{
rgb
}{
0.152,0.250,0.545
}
\begin{tikzpicture}
\begin{tikzpicture}
\begin{axis}
[
\begin{axis}
[
name=s1,
name=s1,
width=7cm, height=4cm,
width=7cm, height=4cm,
xtick=
{
-4,-3,-2,-1,0,1,2,3,4
}
,
xtick=
{
-4,-3,-2,-1,0,1,2,3,4
}
,
ytick=
{
0,1,...,4
}
,
ytick=
{
0,1,...,4
}
,
xticklabel style=
{
opacity=0
}
,
xticklabel style=
{
opacity=0
}
,
yticklabel style=
{
opacity=0
}
,
yticklabel style=
{
opacity=0
}
,
xlabel=
{
$
w
$
}
,
xlabel=
{
\textbf
{$
\textrm
{
W
}_
t
$}
}
,
ylabel=
{
$
L
(
w
)
$
}
,
ylabel=
{
\textbf
{
L(
$
\textrm
{
W
}_
t
$
)
}
}
,
axis line style=
{
->
}
,
axis line style=
{
->
}
,
xlabel style=
{
xshift=2.2cm,yshift=1.2cm
}
,
xlabel style=
{
xshift=2.2cm,yshift=1.2cm
}
,
ylabel style=
{
rotate=-90,xshift=1.5cm,yshift=1.6cm
}
,
ylabel style=
{
rotate=-90,xshift=1.5cm,yshift=1.6cm
}
,
...
@@ -26,16 +26,16 @@
...
@@ -26,16 +26,16 @@
\end{axis}
\end{axis}
\begin{axis}
[
\begin{axis}
[
at=
{
(s1.south)
}
,
at=
{
(s1.south)
}
,
anchor=south,
anchor=south,
xshift=6cm,
xshift=6cm,
yshift=0cm,
yshift=0cm,
width=7cm, height=4cm,
width=7cm, height=4cm,
xtick=
{
-4,-3,-2,-1,0,1,2,3,4
}
,
xtick=
{
-4,-3,-2,-1,0,1,2,3,4
}
,
ytick=
{
0,1,...,4
}
,
ytick=
{
0,1,...,4
}
,
xticklabel style=
{
opacity=0
}
,
xticklabel style=
{
opacity=0
}
,
yticklabel style=
{
opacity=0
}
,
yticklabel style=
{
opacity=0
}
,
xlabel=
{
$
w
$
}
,
xlabel=
{
\textbf
{$
\textrm
{
W
}_
t
$}
}
,
ylabel=
{
$
L
(
w
)
$
}
,
ylabel=
{
\textbf
{
L(
$
\textrm
{
W
}_
t
$
)
}
}
,
axis line style=
{
->
}
,
axis line style=
{
->
}
,
xlabel style=
{
xshift=2.2cm,yshift=1.2cm
}
,
xlabel style=
{
xshift=2.2cm,yshift=1.2cm
}
,
ylabel style=
{
rotate=-90,xshift=1.5cm,yshift=1.6cm
}
,
ylabel style=
{
rotate=-90,xshift=1.5cm,yshift=1.6cm
}
,
...
@@ -52,4 +52,4 @@
...
@@ -52,4 +52,4 @@
\addplot
[quiver=
{
u=-x-(x/abs(x))*(1+x
^
2-4)
^
(1/2),v=-0.7
}
,domain=-3.13:2.6,->,samples=2,red!60,ultra thick]
{
x
^
2/4
}
;
\addplot
[quiver=
{
u=-x-(x/abs(x))*(1+x
^
2-4)
^
(1/2),v=-0.7
}
,domain=-3.13:2.6,->,samples=2,red!60,ultra thick]
{
x
^
2/4
}
;
\addplot
[draw=ublue,fill=red,mark=*] coordinates
{
(0,0)
}
;
\addplot
[draw=ublue,fill=red,mark=*] coordinates
{
(0,0)
}
;
\end{axis}
\end{axis}
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-decode-of-transformer.tex
查看文件 @
08a776fd
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]e2.east)
{
\tiny
{$
e
_
x
()
$}}
;
\node
[rnnnode,anchor=west,fill=green!20] (e3) at ([xshift=1em]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] (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] (w2) at ([yshift=-0.6em]e2.south)
{
\tiny
{
好
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{
<eos>
}}
;
\node
[anchor=north,inner sep=2pt] (w3) at ([yshift=-0.6em]e3.south)
{
\tiny
{
$
\langle
$
eos
$
\rangle
$
}}
;
%\node [anchor=south] (dot1) at ([xshift=0.4em,yshift=-0.7em]h1.south) {\tiny{...}};
%\node [anchor=south] (dot1) at ([xshift=0.4em,yshift=-0.7em]h1.south) {\tiny{...}};
%\node [anchor=south] (dot2) at ([xshift=-0.4em,yshift=-0.7em]h3.south) {\tiny{...}};
%\node [anchor=south] (dot2) at ([xshift=-0.4em,yshift=-0.7em]h3.south) {\tiny{...}};
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
%\node [anchor=west,inner sep=2pt] (o5) at ([xshift=0.3em]o4.east) {\tiny{...}};
%\node [anchor=west,inner sep=2pt] (o5) at ([xshift=0.3em]o4.east) {\tiny{...}};
}
}
{
{
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{
<eos>
}}
;
\node
[anchor=north,inner sep=2pt] (wt1) at ([yshift=-0.6em]t1.south)
{
\tiny
{
$
\langle
$
eos
$
\rangle
$
}}
;
}
}
{
{
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
How
}}
;
\node
[anchor=north,inner sep=2pt] (wt2) at ([yshift=-0.6em]t2.south)
{
\tiny
{
How
}}
;
...
@@ -97,7 +97,7 @@
...
@@ -97,7 +97,7 @@
{
{
\node
[anchor=center,inner sep=2pt] (wo3) at ([yshift=1.2em]o3.north)
{
\tiny
{
you
}}
;
\node
[anchor=center,inner sep=2pt] (wo3) at ([yshift=1.2em]o3.north)
{
\tiny
{
you
}}
;
\node
[anchor=south,inner sep=2pt] (wos3) at (wo3.north)
{
\tiny
{
\textbf
{
[step 3]
}}}
;
\node
[anchor=south,inner sep=2pt] (wos3) at (wo3.north)
{
\tiny
{
\textbf
{
[step 3]
}}}
;
\node
[anchor=center,inner sep=2pt] (wo4) at ([yshift=1.2em]o4.north)
{
\tiny
{
<eos>
}}
;
\node
[anchor=center,inner sep=2pt] (wo4) at ([yshift=1.2em]o4.north)
{
\tiny
{
$
\langle
$
eos
$
\rangle
$
}}
;
\node
[anchor=south,inner sep=2pt] (wos4) at (wo4.north)
{
\tiny
{
\textbf
{
[step 4]
}}}
;
\node
[anchor=south,inner sep=2pt] (wos4) at (wo4.north)
{
\tiny
{
\textbf
{
[step 4]
}}}
;
}
}
...
...
Book/Chapter6/Figures/figure-lrate-of-transformer.tex
查看文件 @
08a776fd
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
width=.60
\textwidth
,
width=.60
\textwidth
,
height=.40
\textwidth
,
height=.40
\textwidth
,
legend style=
{
at=
{
(0.60,0.08)
}
, anchor=south west
}
,
legend style=
{
at=
{
(0.60,0.08)
}
, anchor=south west
}
,
xlabel=
{
\footnotesize
{
更新步数
(10k)
}}
,
xlabel=
{
\footnotesize
{
num update
(10k)
}}
,
ylabel=
{
\footnotesize
{
学习率
(
\scriptsize
{$
10
^{
-
3
}$
)
}}}
,
ylabel=
{
\footnotesize
{
Learn rate
(
\scriptsize
{$
10
^{
-
3
}$
)
}}}
,
ylabel style=
{
yshift=-1em
}
,xlabel style=
{
yshift=0.0em
}
,
ylabel style=
{
yshift=-1em
}
,xlabel style=
{
yshift=0.0em
}
,
yticklabel style=
{
/pgf/number format/precision=2,/pgf/number format/fixed zerofill
}
,
yticklabel style=
{
/pgf/number format/precision=2,/pgf/number format/fixed zerofill
}
,
ymin=0,ymax=0.9, ytick=
{
0.2, 0.4, 0.6, 0.8
}
,
ymin=0,ymax=0.9, ytick=
{
0.2, 0.4, 0.6, 0.8
}
,
...
...
Book/Chapter6/Figures/figure-process06.tex
查看文件 @
08a776fd
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
% step 6
% step 6
{
{
\node
[rnnnode]
(rnn34) at ([xshift=2
\base
]rnn33)
{}
;
\node
[rnnnode]
(rnn34) at ([xshift=2
\base
]rnn33)
{}
;
\node
[wordnode,anchor=south]
(o4) at ([yshift=
\base
]rnn34.north)
{
EOS
}
;
\node
[wordnode,anchor=south]
(o4) at ([yshift=
\base
]rnn34.north)
{
$
\langle
$
eos
$
\rangle
$
}
;
\draw
[-latex']
(rnn33) to (rnn34);
\draw
[-latex']
(rnn33) to (rnn34);
\draw
[-latex']
(rnn24) to (rnn34);
\draw
[-latex']
(rnn24) to (rnn34);
\draw
[-latex']
(rnn34) to (o4);
\draw
[-latex']
(rnn34) to (o4);
...
...
Book/Chapter6/Figures/figure-self-att-vs-enco-deco-att.tex
查看文件 @
08a776fd
\begin{tikzpicture}
\begin{tikzpicture}
\node
[rounded corners=1pt,minimum width=11.0em,minimum height=2.0em,fill=pink!30,draw=black]
(p1) at (0,0)
{
\small
{
Self-Attention
}}
;
\node
[rounded corners=1pt,minimum width=11.0em,minimum height=2.0em,fill=pink!30,draw=black]
(p1) at (0,0)
{
\small
{
Self-Attention
}}
;
...
@@ -13,11 +13,11 @@
...
@@ -13,11 +13,11 @@
\node
[anchor=north,rounded corners=1pt,minimum width=11.0em,minimum height=3.5em,draw=ugreen!70,very thick,dotted]
(p1-1) at ([yshift=-5.2em]p1.south)
{
\small
{
解码端每个位置的表示
}}
;
\node
[anchor=north,rounded corners=1pt,minimum width=11.0em,minimum height=3.5em,draw=ugreen!70,very thick,dotted]
(p1-1) at ([yshift=-5.2em]p1.south)
{
\small
{
解码端每个位置的表示
}}
;
\draw
[->,thick,dashed] (word3.south) .. controls +(south:1
.5em) and +(north:1.5em) .. ([xshift=-0.4em]
p1-1.north);
\draw
[->,thick,dashed] (word3.south) .. controls +(south:1
em) and +(north:1em) .. (
p1-1.north);
\draw
[->,thick,dashed](word1.south) --(p1-1.north);
\draw
[->,thick,dashed](word1.south) --(p1-1.north);
\draw
[->,thick,dashed] (word2.south) .. controls +(south:1
.0em) and +(north:1.5em) .. ([xshift=0.4em]
p1-1.north);
\draw
[->,thick,dashed] (word2.south) .. controls +(south:1
em) and +(north:1em) .. (
p1-1.north);
\node
[anchor=north]
(caption1) at ([xshift=0.0em,yshift=-9.5em]p1.south)
{
\small
{
(a)
Self-Attention的输入
}}
;
\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!30,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!30,draw=black]
(p2) at ([xshift=5.0em]p1.east)
{
\small
{
Encoder-Decoder Attention
}}
;
...
@@ -48,11 +48,11 @@
...
@@ -48,11 +48,11 @@
\draw
[<-,thick,dashed]
([xshift=-3.6em,yshift=-3.2em]word1-2.north)--([xshift=-3.6em,yshift=-3.2em]p2.south);
\draw
[<-,thick,dashed]
([xshift=-3.6em,yshift=-3.2em]word1-2.north)--([xshift=-3.6em,yshift=-3.2em]p2.south);
\draw
[<-,thick,dashed]
([xshift=3.6em,yshift=-3.2em]word1-2.north)--([xshift=3.6em,yshift=-3.2em]p2.south);
\draw
[<-,thick,dashed]
([xshift=3.6em,yshift=-3.2em]word1-2.north)--([xshift=3.6em,yshift=-3.2em]p2.south);
\draw
[->,thick,dashed] (word1-2.south) .. controls +(south:1em) and +(north:1
.5em) .. ([yshift=0.3em,xshift=-0.4
em]p2-3.north);
\draw
[->,thick,dashed] (word1-2.south) .. controls +(south:1em) and +(north:1
em) .. ([yshift=0.3
em]p2-3.north);
\node
[anchor=north]
(caption2) at ([xshift=0.0em,yshift=-9.5em]p2.south)
{
\small
{
(b)
Encoder-Decoder Attention的输入
}}
;
\node
[anchor=north]
(caption2) at ([xshift=0.0em,yshift=-9.5em]p2.south)
{
\small
{
(b)Encoder-Decoder Attention的输入
}}
;
\end{tikzpicture}
\end{tikzpicture}
\ No newline at end of file
Book/Chapter6/Figures/figure-softmax.tex
查看文件 @
08a776fd
\definecolor
{
ublue
}{
rgb
}{
0.152,0.250,0.545
}
\definecolor
{
ublue
}{
rgb
}{
0.152,0.250,0.545
}
\begin{tikzpicture}
\begin{tikzpicture}
\begin{axis}
[
\begin{axis}
[
width=8cm, height=5cm,
width=8cm, height=5cm,
xtick=
{
-6,-4,...,6
}
,
xtick=
{
-6,-4,...,6
}
,
ytick=
{
0,0.5,1
}
,
ytick=
{
0,0.5,1
}
,
xlabel=
{
\small
{
$
x
$
}}
,
xlabel=
{
\small
{
\textbf
{
x
}
}}
,
ylabel=
{
\small
{
Softmax(
$
x
$
)
}}
,
ylabel=
{
\small
{
\textbf
{
Softmax(x)
}
}}
,
xlabel style=
{
xshift=3.0cm,yshift=1cm
}
,
xlabel style=
{
xshift=3.0cm,yshift=1cm
}
,
axis y line=middle,
axis y line=middle,
ylabel style=
{
xshift=-2.4cm,yshift=-0.2cm
}
,
ylabel style=
{
xshift=-2.4cm,yshift=-0.2cm
}
,
...
@@ -22,4 +22,4 @@
...
@@ -22,4 +22,4 @@
\end{axis}
\end{axis}
\end{tikzpicture}
\end{tikzpicture}
%---------------------------------------------------------------------
%---------------------------------------------------------------------
\ No newline at end of file
Book/Chapter6/Figures/figure-structure-of-GNMT.tex
查看文件 @
08a776fd
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
% words
% words
\node
[wnode,below=0pt of encemb1]
(encword1)
{
你
}
;
\node
[wnode,below=0pt of encemb1]
(encword1)
{
你
}
;
\node
[wnode,below=0pt of encemb2]
(encword2)
{
什么
}
;
\node
[wnode,below=0pt of encemb2]
(encword2)
{
什么
}
;
\node
[wnode,below=0pt of encemb4]
(encword4)
{
EOS
}
;
\node
[wnode,below=0pt of encemb4]
(encword4)
{
$
\langle
$
eos
$
\rangle
$
}
;
% connections
% connections
\draw
[-latex']
(enc11) to (enc12);
\draw
[-latex']
(enc11) to (enc12);
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,7 @@
\node
[rnnnode,fill=blue!20,above=\base of dec54]
(softmax4)
{}
;
\node
[rnnnode,fill=blue!20,above=\base of dec54]
(softmax4)
{}
;
% words
% words
\node
[wnode,below=0pt of decemb1]
(decinword1)
{
SOS
}
;
\node
[wnode,below=0pt of decemb1]
(decinword1)
{
$
\langle
$
sos
$
\rangle
$
}
;
\node
[wnode,below=0pt of decemb2]
(decinword2)
{
Have
}
;
\node
[wnode,below=0pt of decemb2]
(decinword2)
{
Have
}
;
\node
[wnode,below=0pt of decemb4]
(decinword4)
{
?
}
;
\node
[wnode,below=0pt of decemb4]
(decinword4)
{
?
}
;
...
@@ -149,7 +149,7 @@
...
@@ -149,7 +149,7 @@
\node
[wnode,anchor=base]
(decoutword2) at (
\XCoord
,
\YCoord
)
{
you
}
;
\node
[wnode,anchor=base]
(decoutword2) at (
\XCoord
,
\YCoord
)
{
you
}
;
\ExtractX
{$
(
softmax
4
.north
)
$}
\ExtractX
{$
(
softmax
4
.north
)
$}
\ExtractY
{$
(
decoutword
1
.base
)
$}
\ExtractY
{$
(
decoutword
1
.base
)
$}
\node
[wnode,anchor=base]
(decoutword4) at (
\XCoord
,
\YCoord
)
{
EOS
}
;
\node
[wnode,anchor=base]
(decoutword4) at (
\XCoord
,
\YCoord
)
{
$
\langle
$
eos
$
\rangle
$
}
;
% connections
% connections
\draw
[-latex']
(dec11) to (dec12);
\draw
[-latex']
(dec11) to (dec12);
...
...
Book/Chapter6/Figures/figure-the-whole-of-LSTM.tex
查看文件 @
08a776fd
...
@@ -154,25 +154,25 @@
...
@@ -154,25 +154,25 @@
\end{scope}
\end{scope}
\begin{pgfonlayer}
{
background
}
\begin{pgfonlayer}
{
background
}
\node
[draw,very thick,rectangle,fill=blue!
1
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\node
[draw,very thick,rectangle,fill=blue!
3
0!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)]
(LSTM)
{}
;
\end{pgfonlayer}
\end{pgfonlayer}
\begin{scope}
\begin{scope}
{
{
% forget gate formula
% forget gate formula
\node
[formulanode,anchor=south east,text width=
10e
m]
() at ([shift=
{
(4
\base
,1.5
\base
)
}
]aux51)
{
遗忘门
\\
$
\mathbf
{
f
}_
t
=
\sigma
(
\mathbf
{
W
}_
f
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
f
)
$}
;
\node
[formulanode,anchor=south east,text width=
3.4c
m]
() at ([shift=
{
(4
\base
,1.5
\base
)
}
]aux51)
{
遗忘门
\\
$
\mathbf
{
f
}_
t
=
\sigma
(
\mathbf
{
W
}_
f
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
f
)
$}
;
}
}
{
{
% input gate formula
% input gate formula
\node
[formulanode,anchor=north east
,text width=10em
]
() at ([shift=
{
(4
\base
,-1.5
\base
)
}
]aux21)
{
输入门
\\
$
\mathbf
{
i
}_
t
=
\sigma
(
\mathbf
{
W
}_
i
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
i
)
$
\\
$
\hat
{
\mathbf
{
c
}}_
t
=
\mathrm
{
tanh
}
(
\mathbf
{
W
}_
c
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
c
)
$}
;
\node
[formulanode,anchor=north east]
() at ([shift=
{
(4
\base
,-1.5
\base
)
}
]aux21)
{
输入门
\\
$
\mathbf
{
i
}_
t
=
\sigma
(
\mathbf
{
W
}_
i
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
i
)
$
\\
$
\hat
{
\mathbf
{
c
}}_
t
=
\mathrm
{
tanh
}
(
\mathbf
{
W
}_
c
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
c
)
$}
;
}
}
{
{
% cell update formula
% cell update formula
\node
[formulanode,anchor=south west,text width=
10e
m]
() at ([shift=
{
(-4
\base
,1.5
\base
)
}
]aux59)
{
记忆更新
\\
$
\mathbf
{
c
}_{
t
}
=
\mathbf
{
f
}_
t
\cdot
\mathbf
{
c
}_{
t
-
1
}
+
\mathbf
{
i
}_
t
\cdot
\hat
{
\mathbf
{
c
}}_
t
$}
;
\node
[formulanode,anchor=south west,text width=
3.02c
m]
() at ([shift=
{
(-4
\base
,1.5
\base
)
}
]aux59)
{
记忆更新
\\
$
\mathbf
{
c
}_{
t
}
=
\mathbf
{
f
}_
t
\cdot
\mathbf
{
c
}_{
t
-
1
}
+
\mathbf
{
i
}_
t
\cdot
\hat
{
\mathbf
{
c
}}_
t
$}
;
}
}
{
{
% output gate formula
% output gate formula
\node
[formulanode,anchor=north west
,text width=10em
]
() at ([shift=
{
(-4
\base
,-1.5
\base
)
}
]aux29)
{
输出门
\\
$
\mathbf
{
o
}_
t
=
\sigma
(
\mathbf
{
W
}_
o
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
o
)
$
\\
$
\mathbf
{
h
}_{
t
}
=
\mathbf
{
o
}_
t
\cdot
\mathrm
{
tanh
}
(
\mathbf
{
c
}_{
t
}
)
$}
;
\node
[formulanode,anchor=north west]
() at ([shift=
{
(-4
\base
,-1.5
\base
)
}
]aux29)
{
输出门
\\
$
\mathbf
{
o
}_
t
=
\sigma
(
\mathbf
{
W
}_
o
[
\mathbf
{
h
}_{
t
-
1
}
,
\mathbf
{
x
}_
t
]+
\mathbf
{
b
}_
o
)
$
\\
$
\mathbf
{
h
}_{
t
}
=
\mathbf
{
o
}_
t
\cdot
\mathrm
{
tanh
}
(
\mathbf
{
c
}_{
t
}
)
$}
;
}
}
\end{scope}
\end{scope}
\end{tikzpicture}
\end{tikzpicture}
...
...
Book/Chapter6/Figures/figure-transformer.tex
查看文件 @
08a776fd
...
@@ -35,9 +35,9 @@
...
@@ -35,9 +35,9 @@
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[outputnode,anchor=south] (o1) at ([yshift=1em]res5.north)
{
\tiny
{$
\textbf
{
Output layer
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[inputnode,anchor=north west] (input2) at ([yshift=-1em]sa2.south west)
{
\tiny
{$
\textbf
{
Embedding
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[posnode,anchor=north east] (pos2) at ([yshift=-1em]sa2.south east)
{
\tiny
{$
\textbf
{
Postion
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
SOS
$
>
$
I am fine
}$}}
;
\node
[anchor=north] (outputs) at ([yshift=-3em]sa2.south)
{
\tiny
{$
\textbf
{
解码器输入:
$
<
$
sos
$
>
$
I am fine
}$}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=east] (decoder) at ([xshift=-1em,yshift=-1.5em]o1.west)
{
\scriptsize
{
\textbf
{
解码器
}}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
EOS
$
>
$
}$}}
;
\node
[anchor=north] (decoutputs) at ([yshift=1.5em]o1.north)
{
\tiny
{$
\textbf
{
解码器输出: I am fine
$
<
$
eos
$
>
$
}$}}
;
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (sa2.north) -- (res3.south);
\draw
[->] (res3.north) -- (ed1.south);
\draw
[->] (res3.north) -- (ed1.south);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论