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
8384e888
Commit
8384e888
authored
Nov 09, 2020
by
zengxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12 figures
parent
c63f0aad
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
36 行增加
和
36 行删除
+36
-36
Chapter12/Figures/figure-decode-of-transformer.tex
+15
-15
Chapter12/Figures/figure-multi-head-attention-model.tex
+3
-3
Chapter12/Figures/figure-point-product-attention-model.tex
+3
-3
Chapter12/Figures/figure-process-of-5.tex
+9
-9
Chapter12/Figures/figure-self-att-vs-enco-deco-att.tex
+6
-6
没有找到文件。
Chapter12/Figures/figure-decode-of-transformer.tex
查看文件 @
8384e888
...
...
@@ -5,9 +5,9 @@
\begin{scope}
\tikzstyle
{
rnnnode
}
= [minimum height=1.1em,minimum width=2.1em,inner sep=2pt,rounded corners=1pt,draw,fill=red!20];
\node
[rnnnode,anchor=west] (h1) at (0,0)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_
1
$}}
;
\node
[rnnnode,anchor=west] (h2) at ([xshift=1em]h1.east)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_
2
$}}
;
\node
[rnnnode,anchor=west] (h3) at ([xshift=1em]h2.east)
{
\tiny
{$
\
vectorn
{
\emph
{
h
}
}_
3
$}}
;
\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=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
()
$}}
;
...
...
@@ -44,18 +44,18 @@
%\node [anchor=west,inner sep=2pt] (t5) at ([xshift=0.3em]t4.east) {\tiny{...}};
}
{
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}
}_
1
$}}
;
\node
[rnnnode,anchor=south] (f1) at ([yshift=1em]s1.north)
{
\tiny
{$
\
vectorn
{
\emph
{
f
}
}_
1
$}}
;
\node
[rnnnode,anchor=south] (s1) at ([yshift=1em]t1.north)
{
\tiny
{$
\
mathbi
{
s
}_
1
$}}
;
\node
[rnnnode,anchor=south] (f1) at ([yshift=1em]s1.north)
{
\tiny
{$
\
mathbi
{
f
}_
1
$}}
;
}
{
\node
[rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}
}_
2
$}}
;
\node
[rnnnode,anchor=south] (f2) at ([yshift=1em]s2.north)
{
\tiny
{$
\
vectorn
{
\emph
{
f
}
}_
2
$}}
;
\node
[rnnnode,anchor=south] (s2) at ([yshift=1em]t2.north)
{
\tiny
{$
\
mathbi
{
s
}_
2
$}}
;
\node
[rnnnode,anchor=south] (f2) at ([yshift=1em]s2.north)
{
\tiny
{$
\
mathbi
{
f
}_
2
$}}
;
}
{
\node
[rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}
}_
3
$}}
;
\node
[rnnnode,anchor=south] (f3) at ([yshift=1em]s3.north)
{
\tiny
{$
\
vectorn
{
\emph
{
f
}
}_
3
$}}
;
\node
[rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north)
{
\tiny
{$
\
vectorn
{
\emph
{
s
}
}_
4
$}}
;
\node
[rnnnode,anchor=south] (f4) at ([yshift=1em]s4.north)
{
\tiny
{$
\
vectorn
{
\emph
{
f
}
}_
4
$}}
;
\node
[rnnnode,anchor=south] (s3) at ([yshift=1em]t3.north)
{
\tiny
{$
\
mathbi
{
s
}_
3
$}}
;
\node
[rnnnode,anchor=south] (f3) at ([yshift=1em]s3.north)
{
\tiny
{$
\
mathbi
{
f
}_
3
$}}
;
\node
[rnnnode,anchor=south] (s4) at ([yshift=1em]t4.north)
{
\tiny
{$
\
mathbi
{
s
}_
4
$}}
;
\node
[rnnnode,anchor=south] (f4) at ([yshift=1em]s4.north)
{
\tiny
{$
\
mathbi
{
f
}_
4
$}}
;
%\node [anchor=west,inner sep=2pt] (s5) at ([xshift=0.3em]s4.east) {\tiny{...}};
%\node [anchor=south] (dot3) at ([xshift=-0.4em,yshift=-0.7em]s3.south) {\tiny{...}};
\node
[anchor=south] (dot4) at ([xshift=-0.4em,yshift=-0.7em]s4.south)
{
\tiny
{
...
}}
;
...
...
@@ -145,7 +145,7 @@
}
{
\node
[circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c1) at ([yshift=2em]h2.north)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}
}_
1
$}}
;
\node
[circle,draw,anchor=south,inner sep=3pt,fill=orange!20] (c1) at ([yshift=2em]h2.north)
{
\tiny
{$
\
mathbi
{
C
}_
1
$}}
;
\node
[anchor=south] (c1label) at (c1.north)
{
\tiny
{
\textbf
{
编码-解码注意力机制:上下文
}}}
;
\draw
[->] (h1.north) .. controls +(north:0.6) and +(250:0.9) .. (c1.250);
\draw
[->] (h2.north) .. controls +(north:0.6) and +(270:0.9) .. (c1.270);
...
...
@@ -155,19 +155,19 @@
}
{
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c2) at ([yshift=-2em]t1.south)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}
}_
2
$}}
;
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c2) at ([yshift=-2em]t1.south)
{
\tiny
{$
\
mathbi
{
C
}_
2
$}}
;
\draw
[->] ([xshift=-0.7em]c2.west) -- ([xshift=-0.1em]c2.west);
\draw
[->] ([xshift=0.1em]c2.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]f2.west);
}
{
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}
}_
3
$}}
;
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c3) at ([yshift=-2em]t2.south)
{
\tiny
{$
\
mathbi
{
C
}_
3
$}}
;
\draw
[->] ([xshift=-0.7em]c3.west) -- ([xshift=-0.1em]c3.west);
\draw
[->] ([xshift=0.1em]c3.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]f3.west);
}
{
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south)
{
\tiny
{$
\
vectorn
{
\emph
{
C
}
}_
4
$}}
;
\node
[circle,draw,anchor=north,inner sep=3pt,fill=orange!20] (c4) at ([yshift=-2em]t3.south)
{
\tiny
{$
\
mathbi
{
C
}_
4
$}}
;
\draw
[->] ([xshift=-0.7em]c4.west) -- ([xshift=-0.1em]c4.west);
\draw
[->] ([xshift=0.1em]c4.east) .. controls +(east:0.6) and +(west:0.8) ..([yshift=-0.3em,xshift=-0.1em]f4.west);
}
...
...
Chapter12/Figures/figure-multi-head-attention-model.tex
查看文件 @
8384e888
...
...
@@ -6,17 +6,17 @@
\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=north] (Q) at ([xshift=0em,yshift=-1em]Linear02.south)
{
\footnotesize
{$
\
vectorn
{
\emph
{
Q
}
}$}}
;
\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=north] (K) at ([xshift=0em,yshift=-1em]Linear12.south)
{
\footnotesize
{$
\
vectorn
{
\emph
{
K
}
}$}}
;
\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=north] (V) at ([xshift=0em,yshift=-1em]Linear22.south)
{
\footnotesize
{$
\
vectorn
{
\emph
{
V
}
}$}}
;
\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
{}}
;
...
...
Chapter12/Figures/figure-point-product-attention-model.tex
查看文件 @
8384e888
...
...
@@ -7,13 +7,13 @@
\begin{scope}
\node
[anchor=south west,fill=white,draw,inner sep=4pt,minimum width=4em,fill=blue!20!white] (MatMul) at (0,0)
{
\tiny
{
MatMul
}}
;
\node
[anchor=north] (Q1) at ([xshift=-1.4em,yshift=-1em]MatMul.south)
{
\footnotesize
{$
\
vectorn
{
\emph
{
Q
}
}$}}
;
\node
[anchor=north] (K1) at ([xshift=1.4em,yshift=-1em]MatMul.south)
{
\footnotesize
{$
\
vectorn
{
\emph
{
K
}
}$}}
;
\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!20,minimum width=3.5em] (Mask) at ([yshift=0.8em]Scale3.north)
{
\tiny
{
Mask(opt.)
}}
;
\node
[anchor=south,draw,inner sep=4pt,fill=ugreen!20!white] (SoftMax) at ([yshift=1em]Mask.north)
{
\tiny
{
SoftMax
}}
;
\node
[anchor=south,draw,minimum width=4em,inner sep=4pt,fill=blue!20!white] (MatMul1) at ([xshift=1.7em,yshift=1em]SoftMax.north)
{
\tiny
{
MatMul
}}
;
\node
[anchor=north] (V1) at ([xshift=2em]K1.north)
{
\footnotesize
{$
\
vectorn
{
\emph
{
V
}
}$}}
;
\node
[anchor=north] (V1) at ([xshift=2em]K1.north)
{
\footnotesize
{$
\
mathbi
{
V
}$}}
;
\node
[anchor=north] (null) at ([yshift=0.8em]MatMul1.north)
{}
;
\draw
[->] ([yshift=0.1em]Q1.north) -- ([xshift=-1.4em,yshift=-0.1em]MatMul.south);
...
...
Chapter12/Figures/figure-process-of-5.tex
查看文件 @
8384e888
...
...
@@ -12,7 +12,7 @@
\rowcolor
{
yellow!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbq.north)
{$
\
vectorn
{
\emph
{
Q
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbq.north)
{$
\
mathbi
{
Q
}$}
;
\node
(comma1) at ([xshift=0.15em,yshift=-2em]tbq.east)
{
,
}
;
...
...
@@ -25,7 +25,7 @@
\rowcolor
{
blue!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbk.north)
{$
\
vectorn
{
\emph
{
K
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbk.north)
{$
\
mathbi
{
K
}$}
;
\node
(comma2) at ([xshift=0.15em,yshift=-2em]tbk.east)
{
,
}
;
...
...
@@ -38,7 +38,7 @@
\rowcolor
{
orange!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv.north)
{$
\
vectorn
{
\emph
{
V
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbv.north)
{$
\
mathbi
{
V
}$}
;
\node
(bra) at ([xshift=0.3em,yshift=0]tbv.east)
{
)
}
;
...
...
@@ -56,7 +56,7 @@
\rowcolor
{
yellow!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbq2.north)
{$
\
vectorn
{
\emph
{
Q
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbq2.north)
{$
\
mathbi
{
Q
}$}
;
% x
...
...
@@ -69,7 +69,7 @@
\cellcolor
{
blue!20
}
&
\cellcolor
{
blue!20
}
&
\cellcolor
{
blue!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbk2.north)
{$
\
vectorn
{
\emph
{
K
}
}^{
\mathrm
{
T
}}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbk2.north)
{$
\
mathbi
{
K
}^{
\mathrm
{
T
}}$}
;
\draw
[-] (5.6,-0.2) -- (8,-0.2);
...
...
@@ -83,7 +83,7 @@
\cellcolor
{
green!20
}
&
\cellcolor
{
green!20
}
&
\cellcolor
{
green!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]mask.north)
{$
\
vectorn
{
\emph
{
Mask
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]mask.north)
{$
\
mathbi
{
Mask
}$}
;
%+
\node
at ([xshift=-0.6em,yshift=0em]mask.west)
{$
+
$}
;
%)
...
...
@@ -98,7 +98,7 @@
\rowcolor
{
orange!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv2.north)
{$
\
vectorn
{
\emph
{
V
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbv2.north)
{$
\
mathbi
{
V
}$}
;
%------------------------------
%第二行
...
...
@@ -131,7 +131,7 @@
\rowcolor
{
orange!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv3.north)
{$
\
vectorn
{
\emph
{
V
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbv3.north)
{$
\
mathbi
{
V
}$}
;
%------------------------------------
%第三行
...
...
@@ -156,7 +156,7 @@
\rowcolor
{
orange!20
}
\\
\hline
\end{tabular}
}
;
\node
at ([xshift=0em,yshift=0.5em]tbv4.north)
{$
\
vectorn
{
\emph
{
V
}
}$}
;
\node
at ([xshift=0em,yshift=0.5em]tbv4.north)
{$
\
mathbi
{
V
}$}
;
%=
\node
(eq4) at ([xshift=0.5em,yshift=0em]tbv4.east)
{
=
}
;
...
...
Chapter12/Figures/figure-self-att-vs-enco-deco-att.tex
查看文件 @
8384e888
...
...
@@ -3,9 +3,9 @@
\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
[anchor=north]
(word1) at ([xshift=0.0em,yshift=-2.0em]p1.south)
{
\small
\
vectorn
{
\emph
{
K
}
}}
;
\node
[anchor=west]
(word2) at ([xshift=2.2em]word1.east)
{
\small
\
vectorn
{
\emph
{
V
}
}}
;
\node
[anchor=east]
(word3) at ([xshift=-2.2em]word1.west)
{
\small
\
vectorn
{
\emph
{
Q
}
}}
;
\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
}}
;
\node
[anchor=east]
(word3) at ([xshift=-2.2em]word1.west)
{
\small
\
mathbi
{
Q
}}
;
\draw
[->,thick]
(word1.north)--(p1.south);
\draw
[->,thick]
([xshift=-3.6em]word1.north)--([xshift=-3.6em]p1.south);
...
...
@@ -21,9 +21,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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=north]
(word1-2) at ([xshift=0.0em,yshift=-2.0em]p2.south)
{
\small
\
vectorn
{
\emph
{
K
}
}}
;
\node
[anchor=west]
(word2-2) at ([xshift=2.2em]word1-2.east)
{
\small
\
vectorn
{
\emph
{
V
}
}}
;
\node
[anchor=east]
(word3-2) at ([xshift=-2.2em]word1-2.west)
{
\small
\
vectorn
{
\emph
{
Q
}
}}
;
\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
}}
;
\node
[anchor=east]
(word3-2) at ([xshift=-2.2em]word1-2.west)
{
\small
\
mathbi
{
Q
}}
;
\draw
[->,thick]
(word1-2.north)--(p2.south);
\draw
[->,thick]
([xshift=-3.6em]word1-2.north)--([xshift=-3.6em]p2.south);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论