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
d5ac0ef2
Commit
d5ac0ef2
authored
Jan 04, 2020
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new updates
parent
90ed014e
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
14 行删除
+36
-14
Section04-Phrasal-and-Syntactic-Models/section04-test.tex
+0
-0
Section04-Phrasal-and-Syntactic-Models/section04.tex
+20
-2
Section06-Neural-Machine-Translation/section06.tex
+16
-12
没有找到文件。
Section04-Phrasal-and-Syntactic-Models/section04-test.tex
查看文件 @
d5ac0ef2
差异被折叠。
点击展开。
Section04-Phrasal-and-Syntactic-Models/section04.tex
查看文件 @
d5ac0ef2
...
...
@@ -4287,6 +4287,8 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$
\end
{
scope
}
\begin
{
scope
}
[
xshift
=
1
.
7
in, yshift
=-
0
.
4
in
]
{
\footnotesize
\node
[
anchor
=
west, rotate
=
60
]
at
(
0
.
8
,
-
0
.
6
)
{
VP
$^{
[1]
}$}
;
\node
[
anchor
=
west, rotate
=
60
]
at
(
1
.
8
,
-
0
.
6
)
{
VBZ
$^{
[2]
}$}
;
\node
[
anchor
=
west, rotate
=
60
]
at
(
2
.
8
,
-
0
.
6
)
{
ADVP
$^{
[3]
}$}
;
...
...
@@ -4298,6 +4300,7 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$
\node
[]
at
(
6
.
2
,
-
3
)
{
VP
$^{
[3]
}$}
;
\node
[]
at
(
6
.
2
,
-
4
)
{
VV
$^{
[4]
}$}
;
\node
[]
at
(
6
.
2
,
-
5
)
{
AS
$^{
[5]
}$}
;
}
\foreach
\i
in
{
1
,...,
5
}{
\foreach
\j
in
{
-
5
,...,
-
1
}{
...
...
@@ -4370,8 +4373,23 @@ NP-BAR(NN$_1$ NP-BAR$_2$) $\to$ NN$_1$ NP-BAR$_2$
%%%------------------------------------------------------------------------------------------------------------
%%% 翻译特征
\begin
{
frame
}{
翻译特征
}
% NiuTrans Manual
\begin
{
frame
}{
特征
}
\begin
{
itemize
}
\item
与短语和层次短语模型一样,句法模型也使用判别式模型进行建模
-
$
\textrm
{
P
}
(d,
\textbf
{
t
}
|
\textbf
{
s
}
) =
\frac
{
\exp
(
\sum
_{
i=1
}^{
M
}
\lambda
_
i
\cdot
h
_
i(d,
\textbf
{
s
}
,
\textbf
{
t
}
))
}{
\sum
_{
d',t'
}
\exp
(
\sum
_{
i=1
}^{
M
}
\lambda
_
i
\cdot
h
_
i(d',
\textbf
{
s
}
,
\textbf
{
t
}
'))
}$
。其中特征权重
$
\{\lambda
_
i
\}
$
可以使用最小错误率训练进行调优,特征函数
$
\{
h
_
i
\}
$
需要用户定义。
\item
<
2
-
> 这里,所有规则满足
$
\langle\ \alpha
_
h,
\beta
_
h
\ \rangle
\to
\langle\ \alpha
_
r,
\beta
_
r,
\sim\ \rangle
$
的形式
\begin
{
itemize
}
\item
$
\alpha
_
h
$
和
$
\beta
_
h
$
是规则左部的源语和目标语部分,对应树结构的根节点
\item
$
\alpha
_
r
$
和
$
\beta
_
r
$
是规则右部的源语和目标语部分,对应树结构
\item
$
\sim
$
表示
$
\alpha
_
r
$
和
$
\beta
_
r
$
中叶子非终结符的对应
\item
此外,定义
$
r(
\alpha
_
r)
$
和
$
r(
\beta
_
r)
$
为源语和目标语树结构的叶子节点序列。例如,对于规则
$
\langle\ \textrm
{
VP
}
,
\textrm
{
VP
}
\ \rangle
\to
\langle\ \textrm
{
VP(PP
}_{
1
}
\ \textrm
{
VP(VV(表示) NN
}_{
2
}
)),
\textrm
{
VP(VBZ(was) VP(VBZ
}_{
2
}
\ \textrm
{
PP
}_{
1
}
))
$
,有
\\
\vspace
{
-
1
.
5
em
}
\begin
{
eqnarray
}
r
(
\alpha
_
r
)
&
=
&
\textrm
{
PP
}_
1
\ \textrm
{
表示 NN
}_
2
\nonumber
\\
r
(
\beta
_
r
)
&
=
&
\textrm
{
was
}
\ \textrm
{
VBZ
}_
2
\ \textrm
{
PP
}_
1
\nonumber
\end
{
eqnarray
}
\end
{
itemize
}
\end
{
itemize
}
\end
{
frame
}
%%%------------------------------------------------------------------------------------------------------------
...
...
Section06-Neural-Machine-Translation/section06.tex
查看文件 @
d5ac0ef2
...
...
@@ -1600,7 +1600,7 @@ NLP问题的隐含结构假设 & 无隐含结构假设,端到端学习 \\
\end{center}
{
\scriptsize
\begin{tabular}
{
l
}
*
$
x
_
t
$
:
上
一层的输出,
$
h
_
t
$
: 同一层上一时刻的隐藏状态
\\
*
$
x
_
t
$
:
前
一层的输出,
$
h
_
t
$
: 同一层上一时刻的隐藏状态
\\
*
$
c
_
t
$
: 同一层上一时刻的记忆
\end{tabular}
}
\end{frame}
...
...
@@ -2546,7 +2546,7 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
\item
翻译出``world''的时候``世界''的权重很大
\end{enumerate}
\item
互译的词通常都会产生较大的注意力权重
\item
注意力的权重
包含了词对齐的信息
\item
注意力的权重
一定程度上反应了词语间的对应关系
\end{itemize}
\begin{center}
\hspace*
{
\fill
}
...
...
@@ -2823,8 +2823,8 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
\begin{itemize}
\item
LSTM遗忘门偏置初始为1,也就是始终选择遗忘记忆
$
c
$
,可以有效防止初始时
$
c
$
里包含的错误信号传播后面所有时刻
\item
网络的其他偏置一般都初始化成0,可以有效防止加入过大或过小的偏置后使得激活函数的输出跑到``饱和区'',也就是梯度接近0的区域,使得训练一开始就无法跳出局部极小
\item
网络的权重矩阵
$
W
$
一般使用Xavier参数初始化方法,可以有效稳定训练过程,特别是对于比较``深''的网络
$$
W
\sim
\mathcal
{
U
}
(-
\sqrt
{
\frac
{
6
}{
d
_{
\mathrm
{
in
}}
+
d
_{
\mathrm
{
out
}}}}
,
\sqrt
{
\frac
{
6
}{
d
_{
\mathrm
{
in
}}
+
d
_{
\mathrm
{
out
}}}}
)
$$
\item
$
d
_{
\mathrm
{
in
}}$
和
$
d
_{
\mathrm
{
out
}}$
分别是
$
W
$
的输入和输出的维度大小,经典的
论文
\\
\item
<2->
网络的权重矩阵
$
W
$
一般使用Xavier参数初始化方法,可以有效稳定训练过程,特别是对于比较``深''的网络
$$
W
\sim
\mathcal
{
U
}
(-
\sqrt
{
\frac
{
6
}{
d
_{
\mathrm
{
in
}}
+
d
_{
\mathrm
{
out
}}}}
,
\sqrt
{
\frac
{
6
}{
d
_{
\mathrm
{
in
}}
+
d
_{
\mathrm
{
out
}}}}
)
$$
$
d
_{
\mathrm
{
in
}}$
和
$
d
_{
\mathrm
{
out
}}$
分别是
$
W
$
的输入和输出的维度大小,参考
论文
\\
\textbf
{
Understanding the difficulty of training deep feedforward neural networks
}
\\
\textbf
{
Glorot, X.,
\&
Bengio, Y., 2010, In Proc of AISTATS
}
\end{itemize}
...
...
@@ -2844,7 +2844,7 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
\end{tabular}
\end{center}
\item
因此需要快速得到模型看一下初步效果,选择Adam
\item
若是需要在一个任务上得到最优的结果,选择SGD
\item
<2->
若是需要在一个任务上得到最优的结果,选择SGD
\begin{itemize}
\item
需要注意的是,训练RNN的时候,我们通常会遇到梯度爆炸的问题,也就是梯度突然变得很大,这种情况下需要使用``梯度裁剪''来防止梯度
$
\pi
$
超过阈值
$$
\pi
'
=
\pi
\cdot
\frac
{
\mathrm
{
threshold
}}{
\max
(
\mathrm
{
threshold
}
,
\parallel
\pi
\parallel
_
2
)
}$$
\item
其中
$
\mathrm
{
threshold
}$
是手工设定的梯度大小阈值,
$
\parallel
\cdot
\parallel
_
2
$
是L2范数
...
...
@@ -2858,9 +2858,11 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
\item
不同优化器需要的学习率不同,比如Adam一般使用
$
0
.
001
$
或
$
0
.
0001
$
,而SGD则在
$
0
.
1
\sim
1
$
之间挑选
\item
但是无论使用哪个优化器,为了保证训练又快又好,我们通常都需要根据当前的更新次数来调整学习率的大小
\begin{itemize}
\item
学习率预热:模型训练初期,梯度通常很大,直接使用很大的学习率很容易让模型跑偏,因此需要学习率有一个从小到大的过程
\item
学习率衰减:模型训练接近收敛的时候,使用大学习率会很容易让模型错过局部极小,因此需要学习率逐渐变小来逼近局部最小
\item
<2->
学习率预热:模型训练初期,梯度通常很大,直接使用很大的学习率很容易让模型跑偏,因此需要学习率有一个从小到大的过程
\item
<2->
学习率衰减:模型训练接近收敛的时候,使用大学习率会很容易让模型错过局部极小,因此需要学习率逐渐变小来逼近局部最小
\end{itemize}
\visible
<2->
{
\begin{center}
\begin{tikzpicture}
\footnotesize
{
...
...
@@ -2880,14 +2882,15 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
}
\end{tikzpicture}
\end{center}
}
\end{itemize}
\end{frame}
\begin{frame}
{
训练 - 加速
}
\begin{itemize}
\item
万事俱备,只是为什么训练这么慢?
\visible
<2>
{
\alert
{
- RNN需要等前面所有时刻都完成计算以后才能开始计算当前时刻的输出
}}
\item
我有钱,是不是多买几台设备会更快?
\visible
<2>
{
\alert
{
- 可以,但是需要技巧,而且也不是无限增长的
}}
\item
<
2
> 使用多个设备并行计算进行加速的两种方法
\item
万事俱备,只是为什么训练这么慢?
\visible
<2
-
>
{
\alert
{
- RNN需要等前面所有时刻都完成计算以后才能开始计算当前时刻的输出
}}
\item
我有钱,是不是多买几台设备会更快?
\visible
<2
-
>
{
\alert
{
- 可以,但是需要技巧,而且也不是无限增长的
}}
\item
<
3
> 使用多个设备并行计算进行加速的两种方法
\begin{itemize}
\item
数据并行:把``输入''分到不同设备上并行计算
\item
模型并行:把``模型''分到不同设备上并行计算
...
...
@@ -2901,7 +2904,8 @@ $\textrm{``you''} = \argmax_{y} \textrm{P}(y|\textbf{s}_1, \alert{\textbf{C}})$
模型并行
&
\specialcell
{
l
}{
可以对很大的模型进行
\\
运算
}
&
\specialcell
{
l
}{
只能有限并行,比如
\\
多少层就多少个设备
}
\\
\end{tabular}
\end{center}
\item
<2> 这两种方法可以一起使用!!!
\vspace
{
0.5em
}
\item
<3> 这两种方法可以一起使用!!!
\end{itemize}
\end{frame}
...
...
@@ -4578,7 +4582,7 @@ PE_{(pos,2i+1)} = cos(pos/10000^{2i/d_{model}})
}
\visible
<3->
{
\filldraw
[fill=blue!20,draw,thick,fill opacity=0.85] ([xshift=-0.9em,yshift=0.5em]a15.north west) -- ([xshift=0.5em,yshift=-0.9em]a51.south east) -- ([xshift=0.5em,yshift=0.5em]a55.north east) -- ([xshift=-0.9em,yshift=0.5em]a15.north west);
\node
[anchor=west]
(labelmask) at ([xshift=0.3em,yshift=0.5em]a23.north east)
{
Mask
}
;
\node
[anchor=west]
(labelmask) at ([xshift=0.3em,yshift=0.5em]a23.north east)
{
Mask
ed
}
;
\node
[rounded corners=0.3em,anchor=west,fill=blue!20] (mask) at ([xshift=0.1em]add.east)
{
\large
{$
Mask
$}}
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论