Commit 507e1ca3 by xiaotong

page of MLP for function approximation

parent a79e7d50
......@@ -390,18 +390,19 @@ cycle}
\item 我们可以重复上面的过程,构建\textbf{多层神经网络}
\end{itemize}
\vspace{-0.5em}
\vspace{-1.0em}
\begin{center}
\begin{tikzpicture}
\begin{scope}[]
\def\neuronsep{1.6}
\tikzstyle{neuronnode} = [minimum size=1.5em,circle,draw,ublue,very thick,fill=white,drop shadow={shadow xshift=0.1em,shadow yshift=-0.1em}]
\tikzstyle{neuronnode} = [minimum size=1.7em,circle,draw,ublue,very thick,inner sep=1pt, fill=white,align=center,drop shadow={shadow xshift=0.1em,shadow yshift=-0.1em}]
%%% layer 1
\foreach \n in {1,...,5}{
\node [neuronnode] (neuron0\n) at (\n * \neuronsep,0) {};
\node [neuronnode] (neuron0\n) at (\n * \neuronsep,0) {\tiny{$f_1$}\\[-1ex] \tiny{$\sum$}};
\draw [-,ublue] (neuron0\n.east) -- (neuron0\n.west);
}
\foreach \n in {1,...,5}{
......@@ -421,19 +422,20 @@ cycle}
\node [rectangle,inner sep=0.2em,fill=red!20] [fit = (neuron01) (neuron05)] (layer01) {};
\end{pgfonlayer}
\node [anchor=west] (layer00label) at ([xshift=1.2em]x5.east) {输入层};
\node [anchor=west] (layer00label) at ([xshift=1.25em]x5.east) {\alert{输入层}};
\visible<2->{
\node [anchor=west] (layer01label) at ([xshift=1em]layer01.east) {};
\node [anchor=west] (layer01label) at ([xshift=1em]layer01.east) {};
}
\visible<4->{
\node [anchor=west] (layer01label2) at (layer01label.east) {(\alert{输入})};
\node [anchor=west] (layer01label2) at (layer01label.east) {(\alert{})};
}
%%% layer 2
\visible<2->{
\foreach \n in {2,...,4}{
\node [neuronnode] (neuron1\n) at (\n * \neuronsep,4em) {};
\node [neuronnode] (neuron1\n) at (\n * \neuronsep,4em) {\tiny{$f_2$}\\[-1ex] \tiny{$\sum$}};
\draw [-,ublue] (neuron1\n.east) -- (neuron1\n.west);
}
\foreach \n in {2,...,4}{
......@@ -454,7 +456,7 @@ cycle}
}
\end{pgfonlayer}
\node [anchor=west] (layer02label) at ([xshift=4.9em]layer02.east) {};
\node [anchor=west] (layer02label) at ([xshift=4.9em]layer02.east) {};
\visible<4->{
\node [anchor=west] (layer02label2) at (layer02label.east) {(\alert{隐层})};
}
......@@ -463,7 +465,8 @@ cycle}
%%% layer 3
\visible<3->{
\foreach \n in {1,...,5}{
\node [neuronnode] (neuron2\n) at (\n * \neuronsep,8em) {};
\node [neuronnode] (neuron2\n) at (\n * \neuronsep,8em) {\tiny{$f_3$}\\[-1ex] \tiny{$\sum$}};
\draw [-,ublue] (neuron2\n.east) -- (neuron2\n.west);
}
\foreach \n in {1,...,5}{
......@@ -483,7 +486,7 @@ cycle}
}
\end{pgfonlayer}
\node [anchor=west] (layer03label) at ([xshift=1em]layer03.east) {};
\node [anchor=west] (layer03label) at ([xshift=1em]layer03.east) {};
\visible<4->{
\node [anchor=west] (layer03label2) at (layer03label.east) {(\alert{输出层})};
}
......@@ -497,11 +500,77 @@ cycle}
%%%------------------------------------------------------------------------------------------------------------
%%% 两层神经网络可以逼近任何函数
\begin{frame}{多层神经网络的函数逼近能力}
\begin{frame}{多层神经网络可以逼近任意函数}
\begin{itemize}
\item \textbf{单层神经网络}:线性变换 + 激活函数(非线性)
\item 我们可以重复上面的过程,构建\textbf{多层神经网络}
\item 以一个简单的两层网络为例(隐层激活函数:sigmoid)
\end{itemize}
\begin{center}
\begin{tikzpicture}
%% a two-layer neural network
\begin{scope}
\tikzstyle{neuronnode} = [minimum size=1.7em,circle,draw,ublue,very thick,inner sep=1pt, fill=white,align=center,drop shadow={shadow xshift=0.1em,shadow yshift=-0.1em}]
%% input and hidden layers
\node [neuronnode] (n10) at (0,0) {\tiny{$f$}\\[-1ex] \tiny{$\sum$}};
\node [neuronnode] (n11) at (1.5,0) {\tiny{$f$}\\[-1ex] \tiny{$\sum$}};
\draw [-,ublue] (n10.west) -- (n10.east);
\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$};
\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);
\draw [->,thick,purple] (x1.north) -- ([yshift=-0.1em]n11.south);
%% 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);
\node [] (y) at ([yshift=3em]n20.north) {$y$};
\draw [->,thick] ([yshift=0.1em]n20.north) -- (y.south);
%% 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$}};
\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$}};
\begin{scope}
\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$}};
\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}
\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);
\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);
\node [anchor=north west,align=left] (wblabel) at (-2,2) {\scriptsize{$w_1=1$}\\[-0ex] \scriptsize{\ $b_1=0$}};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{center}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论