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
e3e0898d
Commit
e3e0898d
authored
Sep 18, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new page finished
parent
507e1ca3
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
151 行增加
和
20 行删除
+151
-20
Section05-Neural-Networks-and-Language-Modeling/section05-test.tex
+151
-20
没有找到文件。
Section05-Neural-Networks-and-Language-Modeling/section05-test.tex
查看文件 @
e3e0898d
...
...
@@ -18,6 +18,7 @@
\usepackage
{
changepage
}
\usepackage
{
pgfplots
}
\usepackage
{
subfigure
}
\usepackage
{
pgf-umlcd
}
\usetikzlibrary
{
arrows,decorations.pathreplacing
}
\usetikzlibrary
{
shadows
}
% LATEX and plain TEX when using Tik Z
...
...
@@ -66,6 +67,26 @@
{
\newcommand
{
\mycfont
}{
you
}}
{
\newcommand
{
\mycfont
}{
gbsn
}}
% we use this function to plot a curve
\def\curveh
#1
{
0.2 * (#1 +0.4)
^
3 + 1.2 - 0.3 *(#1 + 0.8)
^
2
}
%\newcommand{\curvehh}[1]{0.2 * (#1 +0.4)^3 + 1.2 - 0.3 *(#1 + 0.8)^2}
\newcommand
{
\curvehh
}
[1]
{
#1
}
\newcommand
{
\curvehhh
}{
1
}
\newcommand
{
\hish
}{
1
}
\renewcommand
{
\unidirectionalAssociation
}
[4]
{
\draw
[umlcd style, ->]
(#1) -- (#4)
% <------
node[near end, auto]
{
#2
}
node[near end, auto,swap]
{
#3
}
;
}
\newcommand
{
\curvehis
}
[3]
{
\draw
[-] (#1 - #3,0) -- (#1 - #3, 0.2 * (#2 +0.4)
^
3 + 1.2 - 0.3 *(#2 + 0.8)
^
2);
}
\begin{CJK}
{
UTF8
}{
\mycfont
}
\end{CJK}
...
...
@@ -502,7 +523,7 @@ cycle}
%%% 两层神经网络可以逼近任何函数
\begin{frame}
{
多层神经网络可以逼近任意函数
}
\begin{itemize}
\item
以一个简单的
两
层网络为例(隐层激活函数:sigmoid)
\item
以一个简单的
三
层网络为例(隐层激活函数:sigmoid)
\end{itemize}
\begin{center}
...
...
@@ -519,52 +540,162 @@ cycle}
\draw
[-,ublue] (n11.west) -- (n11.east);
\node
[anchor=north] (x1) at ([yshift=-6em]n11.south)
{$
x
_
1
$}
;
\node
[anchor=north] (b) at ([yshift=-6em]n10.south)
{$
b
$}
;
\visible
<1-10>
{
\draw
[->,thick] (b.north) -- ([yshift=-0.1em]n10.south);
\draw
[->,thick] (x1.north) -- ([yshift=-0.1em]n10.290);
}
\visible
<1>
{
\draw
[->,thick] (b.north) -- ([yshift=-0.1em]n11.250);
\draw
[->,thick] (x1.north) -- ([yshift=-0.1em]n11.south);
}
\visible
<11->
{
\draw
[->,thick,red] (b.north) -- ([yshift=-0.1em]n10.south);
\draw
[->,thick,blue] (b.north) -- ([yshift=-0.1em]n11.250);
\draw
[->,thick,ugreen] (x1.north) -- ([yshift=-0.1em]n10.290);
}
\visible
<2->
{
\draw
[->,thick,blue] (b.north) -- ([yshift=-0.1em]n11.250);
\draw
[->,thick,purple] (x1.north) -- ([yshift=-0.1em]n11.south);
}
\visible
<15->
{
\node
[neuronnode] (n12) at (2.7,0)
{
\tiny
{$
f
$}
\\
[-1ex]
\tiny
{$
\sum
$}}
;
\node
[neuronnode] (n13) at (3.8,0)
{
\tiny
{$
f
$}
\\
[-1ex]
\tiny
{$
\sum
$}}
;
\draw
[-,ublue] (n12.west) -- (n12.east);
\draw
[-,ublue] (n13.west) -- (n13.east);
\draw
[->,thick] (b.north) -- ([yshift=-0.1em]n12.250);
\draw
[->,thick] (x1.north) -- ([yshift=-0.1em]n12.270);
\draw
[->,thick] (b.north) -- ([yshift=-0.1em]n13.230);
\draw
[->,thick] (x1.north) -- ([yshift=-0.1em]n13.250);
}
\visible
<16->
{
\node
[anchor=west] (morenodes) at (n13.east)
{
...
}
;
}
%% output layers
\node
[neuronnode] (n20) at (0.75,5em)
{
\scriptsize
{$
\sum
$}}
;
\draw
[->,thick] ([yshift=0.1em]n10.north) -- ([yshift=-0.1em]n20.250);
\draw
[->,thick] ([yshift=0.1em]n11.north) -- ([yshift=-0.1em]n20.290);
\visible
<1-10>
{
\draw
[->,thick] ([yshift=0.1em]n10.north) -- ([yshift=-0.1em]n20.250);
}
\visible
<1-8>
{
\draw
[->,thick] ([yshift=0.1em]n11.north) -- ([yshift=-0.1em]n20.290);
}
\visible
<11->
{
\draw
[->,thick,brown] ([yshift=0.1em]n10.north) -- ([yshift=-0.1em]n20.250);
}
\visible
<9->
{
\draw
[->,thick,orange] ([yshift=0.1em]n11.north) -- ([yshift=-0.1em]n20.290);
}
\node
[] (y) at ([yshift=3em]n20.north)
{$
y
$}
;
\draw
[->,thick] ([yshift=0.1em]n20.north) -- (y.south);
\visible
<15->
{
\draw
[->,thick] ([yshift=0.1em]n12.north) -- ([yshift=-0.1em]n20.310);
\draw
[->,thick] ([yshift=0.1em]n13.north) -- ([yshift=-0.1em]n20.330);
}
%% weight and bias
\node
[anchor=center,rotate=90] (b0) at ([yshift=3em,xshift=-0.5em]b.north)
{
\tiny
{$
b
=
0
$}}
;
\node
[anchor=center,rotate=59,fill=white,inner sep=1pt] (b1) at ([yshift=4.9em,xshift=2.2em]b.north)
{
\tiny
{$
b
=
0
$}}
;
\node
[anchor=center,rotate=90] (w1) at ([yshift=3em,xshift=0.5em]x1.north)
{
\tiny
{$
w
=
1
$}}
;
\node
[anchor=center,rotate=-59,fill=white,inner sep=1pt] (w2) at ([yshift=1.2em,xshift=-1.2em]x1.north)
{
\tiny
{$
w
=
0
$}}
;
\visible
<11->
{
\node
[anchor=center,rotate=90,fill=white,inner sep=1pt] (b0) at ([yshift=3em,xshift=-0.5em]b.north)
{
\tiny
{$
b
=-
6
$}}
;
}
\visible
<11->
{
\node
[anchor=center,rotate=-59,fill=white,inner sep=1pt] (w2) at ([yshift=1.2em,xshift=-1.2em]x1.north)
{
\tiny
{$
w
=
100
$}}
;
}
\visible
<2-6>
{
\node
[anchor=center,rotate=59,fill=white,inner sep=1pt] (b1) at ([yshift=4.9em,xshift=2.2em]b.north)
{
\tiny
{$
b
=
0
$}}
;
}
\visible
<7>
{
\node
[anchor=center,rotate=59,fill=white,inner sep=1pt] (b1) at ([yshift=4.9em,xshift=2.2em]b.north)
{
\tiny
{$
b
=-
2
$}}
;
}
\visible
<8->
{
\node
[anchor=center,rotate=59,fill=white,inner sep=1pt] (b1) at ([yshift=4.9em,xshift=2.2em]b.north)
{
\tiny
{$
b
=-
4
$}}
;
}
\visible
<2-4>
{
\node
[anchor=center,rotate=90,fill=white,inner sep=1pt] (w1) at ([yshift=3em,xshift=0.5em]x1.north)
{
\tiny
{$
w
=
1
$}}
;
}
\visible
<5>
{
\node
[anchor=center,rotate=90,fill=white,inner sep=1pt] (w1) at ([yshift=3em,xshift=0.5em]x1.north)
{
\tiny
{$
w
=
10
$}}
;
}
\visible
<6->
{
\node
[anchor=center,rotate=90,fill=white,inner sep=1pt] (w1) at ([yshift=3em,xshift=0.5em]x1.north)
{
\tiny
{$
w
=
100
$}}
;
}
\visible
<11>
{
\node
[anchor=center,rotate=62,fill=white,inner sep=1pt] (w21) at ([yshift=2em,xshift=0.5em]n10.north)
{
\tiny
{$
w'
=
0
.
7
$}}
;
}
\visible
<12->
{
\node
[anchor=center,rotate=62,fill=white,inner sep=1pt] (w21) at ([yshift=2em,xshift=0.5em]n10.north)
{
\tiny
{$
w'
=-
0
.
7
$}}
;
}
\visible
<2-8>
{
\node
[anchor=center,rotate=-62,fill=white,inner sep=1pt] (w22) at ([yshift=2em,xshift=-0.5em]n11.north)
{
\tiny
{$
w'
=
1
$}}
;
}
\visible
<9>
{
\node
[anchor=center,rotate=-62,fill=white,inner sep=1pt] (w22) at ([yshift=2em,xshift=-0.5em]n11.north)
{
\tiny
{$
w'
=
0
.
9
$}}
;
}
\visible
<10->
{
\node
[anchor=center,rotate=-62,fill=white,inner sep=1pt] (w22) at ([yshift=2em,xshift=-0.5em]n11.north)
{
\tiny
{$
w'
=
0
.
7
$}}
;
}
\node
[anchor=center,rotate=62,fill=white,inner sep=1pt] (w21) at ([yshift=2em,xshift=0.5em]n10.north)
{
\tiny
{$
w
=
0
$}}
;
\node
[anchor=center,rotate=-62,fill=white,inner sep=1pt] (w22) at ([yshift=2em,xshift=-0.5em]n11.north)
{
\tiny
{$
w
=
0
$}}
;
%% sigmoid box
\begin{scope}
\visible
<3->
{
\node
[anchor=west] (flabel) at ([xshift=1.2in]y.east)
{
\footnotesize
{
sigmoid:
}}
;
\node
[anchor=west,inner sep=2pt] (flabel2) at (flabel.east)
{
\footnotesize
{$
f
(
x
)=
1
/(
1
+
e
^{
-
x
}
)
$}}
;
\node
[anchor=north west,inner sep=2pt] (flabel3) at (flabel2.south west)
{
\footnotesize
{$
s
=
x
_
1
\cdot
w
+
b
$}}
;
\node
[anchor=north east] (slabel) at ([xshift=0]flabel.south east)
{
\footnotesize
{
sum:
}}
;
\node
[anchor=west,inner sep=2pt] (flabel2) at (flabel.east)
{
\footnotesize
{$
f
(
s
)=
1
/(
1
+
e
^{
-
s
}
)
$}}
;
\node
[anchor=west,inner sep=2pt] (flabel3) at (slabel.east)
{
\footnotesize
{$
s
=
x
_
1
\cdot
w
+
b
$}}
;
\draw
[->,thick,dotted] ([yshift=-0.3em,xshift=-0.1em]n11.60) .. controls +(east:1) and +(west:2) .. ([xshift=-0.2em]flabel.west) ;
\begin{pgfonlayer}
{
background
}
\visible
<3->
{
\node
[rectangle,inner sep=0.2em,fill=blue!20,drop shadow=
{
shadow xshift=0.1em,shadow yshift=-0.1em
}
] [fit = (flabel) (flabel2) (flabel3)] (funcbox)
{}
;
}
\end{pgfonlayer}
}
\end{scope}
\begin{scope}
[xshift=2.8in,yshift=0.2in]
\draw
[->,thick] (-2,0) -- (2,0);
%% output illustration
\begin{scope}
[xshift=2.8in,yshift=0.1in]
\visible
<4->
{
\draw
[->,thick] (-2.2,0) -- (2.2,0);
\draw
[->,thick] (0,0) -- (0,2);
\draw
[-] (-0.05,1) -- (0.05,1);
\node
[anchor=east,inner sep=1pt] (label1) at (0,1)
{
\tiny
{
1
}}
;
\node
[anchor=south east,inner sep=1pt] (label2) at (0,0)
{
\tiny
{
0
}}
;
\draw
[-,very thick,ublue,domain=-2:2,samples=100] plot (
\x
,
{
1/(1+exp(-2*
\x
))
}
);
\draw
[-,very thick,ublue,domain=-2:2,samples=100] plot (
\x
,
{
1/(1+exp(-4*
\x
))
}
);
\draw
[-,very thick,ublue,rounded corners=0.2em] (-2,0) -- (0,0) -- (0,1) -- (2,1);
\draw
[-,very thick,ublue,rounded corners=0.2em] (-2,0) -- (0.25,0) -- (0.25,1) -- (2,1);
\draw
[-,very thick,ublue,rounded corners=0.2em] (-2,0) -- (0.5,0) -- (0.5,1) -- (2,1);
}
\visible
<4>
{
\draw
[-,very thick,ublue,domain=-2:2,samples=100] plot (
\x
,
{
1/(1+exp(-2*
\x
))
}
);
}
\visible
<5>
{
\draw
[-,very thick,ublue,domain=-2:2,samples=100] plot (
\x
,
{
1/(1+exp(-4*
\x
))
}
);
}
\visible
<6>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0,0) -- (0,1) -- (2,1);
}
\visible
<7>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.25,0) -- (0.25,1) -- (2,1);
}
\visible
<8>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.5,0) -- (0.5,1) -- (2,1);
}
\visible
<9>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.5,0) -- (0.5,0.9) -- (2,0.9);
}
\visible
<10>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.5,0) -- (0.5,0.7) -- (2,0.7);
}
\visible
<11>
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.5,0) -- (0.5,0.7) -- (0.7,0.7) -- (0.7,1.4) -- (2,1.4);
}
\visible
<12->
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.5,0) -- (0.5,0.7) -- (0.7,0.7) -- (0.7,0) -- (2,0);
}
\visible
<15->
{
\draw
[-,very thick,ublue,rounded corners=0.1em] (-2,0) -- (0.7,0) -- (0.7,0.6) -- (0.9,0.6) -- (0.9,0) -- (2,0);
}
\visible
<14>
{
\draw
[->,dashed] (0.6,-0.05) -- (0.6,-0.96in);
}
\visible
<15->
{
\draw
[->,dashed] (0.8,-0.05) -- (0.8,-0.98in);
}
\visible
<4>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\scriptsize
{$
w
_
1
=
1
$}
\\
[-0ex]
\scriptsize
{
\
$
b
_
1
=
0
$}}
;
}
\visible
<5>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\alert
{
\scriptsize
{$
w
_
1
=
10
$}}
\\
[-0ex]
\scriptsize
{
\
$
b
_
1
=
0
$}}
;
}
\visible
<6>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\alert
{
\scriptsize
{$
w
_
1
=
100
$}}
\\
[-0ex]
\scriptsize
{
\
$
b
_
1
=
0
$}}
;
}
\visible
<7>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\scriptsize
{$
w
_
1
=
100
$}
\\
[-0ex]
\alert
{
\scriptsize
{
\
$
b
_
1
=-
2
$}}}
;
}
\visible
<8>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\scriptsize
{$
w
_
1
=
100
$}
\\
[-0ex]
\alert
{
\scriptsize
{
\
$
b
_
1
=-
4
$}}}
;
}
\visible
<9>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\alert
{
\scriptsize
{$
w'
_
1
=
0
.
9
$}}}
;
}
\visible
<10>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\alert
{
\scriptsize
{$
w'
_
1
=
0
.
7
$}}}
;
}
\visible
<11>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\alert
{
\scriptsize
{$
w
_
2
=
100
$}}
\\
[-0ex]
\alert
{
\scriptsize
{
\
$
b
_
2
=-
6
$}}
\\
[-0ex]
\alert
{
\scriptsize
{
\
$
w'
_
2
=
0
.
7
$}}}
;
}
\visible
<12>
{
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\scriptsize
{$
w
_
2
=
100
$}
\\
[-0ex]
\scriptsize
{
\
$
b
_
2
=-
6
$}
\\
[-0ex]
\alert
{
\scriptsize
{
\
$
w'
_
2
=-
0
.
7
$}}}
;
}
\visible
<13->
{
\node
[anchor=north west,align=left] (wblabel) at (-2.5,2)
{
\scriptsize
{
这是一个
}
\\
[-1ex]
\scriptsize
{
step function
}}
;
}
\end{scope}
\begin{scope}
[xshift=2.8in,yshift=-1.2in]
\visible
<13->
{
\draw
[->,thick] (-2.2,0) -- (2.2,0);
\draw
[->,thick] (0,0) -- (0,2);
\draw
[-,very thick,red,domain=-1.98:2,samples=100] plot (
\x
,
{
0.2 * (
\x
+0.4)
^
3 + 1.2 - 0.3 *(
\x
+ 0.8)
^
2
}
);
}
\visible
<14->
{
\foreach
\n
in
{
0.5
}{
\pgfmathsetmacro
{
\result
}{
0.2 * (
\n
+ 0.1 + 0.4)
^
3 + 1.2 - 0.3 *(
\n
+ 0.1 + 0.8)
^
2
}
%
\draw
[-,ublue,thick] (
\n
,0) -- (
\n
,
\result
) -- (
\n
+ 0.2,
\result
) -- (
\n
+ 0.2, 0);
}
}
\visible
<15->
{
\foreach
\n
in
{
0.7
}{
\pgfmathsetmacro
{
\result
}{
0.2 * (
\n
+ 0.1 + 0.4)
^
3 + 1.2 - 0.3 *(
\n
+ 0.1 + 0.8)
^
2
}
%
\draw
[-,ublue,thick] (
\n
,0) -- (
\n
,
\result
) -- (
\n
+ 0.2,
\result
) -- (
\n
+ 0.2, 0);
}
}
\visible
<16->
{
\foreach
\n
in
{
-1.9,-1.7,...,1.9
}{
\pgfmathsetmacro
{
\result
}{
0.2 * (
\n
+ 0.1 + 0.4)
^
3 + 1.2 - 0.3 *(
\n
+ 0.1 + 0.8)
^
2
}
%
\draw
[-,ublue,thick] (
\n
,0) -- (
\n
,
\result
) -- (
\n
+ 0.2,
\result
) -- (
\n
+ 0.2, 0);
}
}
\visible
<14>
{
\node
[anchor=north west,align=left] (wblabel) at (-2.5,2.5)
{
\scriptsize
{
函数的每一段都可
}
\\
[-1ex]
\scriptsize
{
由step function
}
\\
[-1ex]
\scriptsize
{
近似
}}
;
}
\visible
<15>
{
\node
[anchor=north west,align=left] (wblabel) at (-2.5,2.5)
{
\scriptsize
{
增加因层神经元
}
\\
[-1ex]
\scriptsize
{
可以拟合更多的
}
\\
[-1ex]
\scriptsize
{
部分
}}
;
}
\visible
<16>
{
\node
[anchor=north west,align=left] (wblabel) at (-2.5,2.5)
{
\scriptsize
{
理论上足够多的
}
\\
[-1ex]
\scriptsize
{
隐层神经元可以
}
\\
[-1ex]
\scriptsize
{
拟合
\alert
{
任意函数
}}}
;
}
\node
[anchor=north west,align=left] (wblabel) at (-2,2)
{
\scriptsize
{$
w
_
1
=
1
$}
\\
[-0ex]
\scriptsize
{
\
$
b
_
1
=
0
$}}
;
\end{scope}
\end{scope}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论