Commit 90dbce0f by xiaotong

example of perceptron

parent ccc94355
...@@ -311,7 +311,7 @@ y = f(w \cdot x + b) ...@@ -311,7 +311,7 @@ y = f(w \cdot x + b)
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\node [anchor=center,circle,draw,thick,minimum size=3em] (neuron) at (0,0) {}; \node [anchor=center,circle,draw,ublue,very thick,minimum size=3.5em,fill=white,drop shadow] (neuron) at (0,0) {};
\node [anchor=east] (x1) at ([xshift=-6em]neuron.west) {\Large{$x_1$}}; \node [anchor=east] (x1) at ([xshift=-6em]neuron.west) {\Large{$x_1$}};
\node [anchor=center] (x0) at ([yshift=3em]x1.center) {\Large{$x_0$}}; \node [anchor=center] (x0) at ([yshift=3em]x1.center) {\Large{$x_0$}};
\node [anchor=center] (x2) at ([yshift=-3em]x1.center) {\Large{$x_2$}}; \node [anchor=center] (x2) at ([yshift=-3em]x1.center) {\Large{$x_2$}};
...@@ -358,7 +358,7 @@ y = f(w \cdot x + b) ...@@ -358,7 +358,7 @@ y = f(w \cdot x + b)
\begin{itemize} \begin{itemize}
\item $x_0$:剧场是否离你足够近? \item $x_0$:剧场是否离你足够近?
\item $x_1$:票价是否低于300元? \item $x_1$:票价是否低于300元?
\item $x_2$:女朋友是否愿意一起 \item $x_2$:女朋友是否喜欢音乐会
\end{itemize} \end{itemize}
\item<2-> 如何决定?比如,女朋友很希望和你一起,但是剧场很远而且票价500元。如果这些因素对你的决策都是同等重要的,那么会有一个综合得分: \item<2-> 如何决定?比如,女朋友很希望和你一起,但是剧场很远而且票价500元。如果这些因素对你的决策都是同等重要的,那么会有一个综合得分:
\begin{displaymath} \begin{displaymath}
...@@ -373,26 +373,26 @@ y = f(w \cdot x + b) ...@@ -373,26 +373,26 @@ y = f(w \cdot x + b)
\end{frame} \end{frame}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
%%% 感知机 - 一个例子(cont) %%% 感知机 - 一个例子:权重
\begin{frame}{一个例子(继续)} \begin{frame}{一个例子 - 权重}
\begin{itemize} \begin{itemize}
\item 可以看出,实际上这个决策过程本质上就是一个感知机 \item 可以看出,实际上这个决策过程本质上就是一个感知机
\item<2-> 但是,人并不是完美的,往往对有些事情会更在意一些。如果你是\textbf{守财奴},因此会对票价看的更重一些,这时你会用不均匀的权重计算每个因素的影响,比如:$w_0=0.5$$w_1=2$$w_2=0.5$ \item<2-> 但是,人并不是完美的,往往对有些事情会更在意一些。如果你是\textbf{守财奴},因此会对票价看的更重一些,这时你会用不均匀的权重计算每个因素的影响,比如:$w_0=0.5$$w_1=2$$w_2=0.5$
\item<3-> 女友很希望和你一起,但是剧场很远而且票价500元,会导致你\alert{选择不去}看音乐会(女朋友都不要了,咋整) \item<3-> 女友很希望和你一起,但是剧场很远而且票价500元,会导致你\alert{选择不去}看音乐会(女朋友都不要了,咋整)
\begin{displaymath} \begin{displaymath}
\sum_i x_i \cdot w_i = 0 \cdot 0.5 + 0 \cdot 2 + 1 \cdot 0.5 = 0.5 < \sigma = 1 \sum_i x_i \cdot w_i = 0 \cdot 0.5 + 0 \cdot 2 + 1 \cdot 0.5 = 0.5 < \sigma = 1
\end{displaymath} \end{displaymath}
\end{itemize} \end{itemize}
\vspace{-0.8em} \vspace{-1.8em}
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope} \begin{scope}
\node [anchor=center,circle,draw,thick,minimum size=3em] (neuron) at (0,0) {}; \node [anchor=center,circle,draw,ublue,very thick,minimum size=3.5em,fill=white,drop shadow] (neuron) at (0,0) {};
\node [anchor=east] (x1) at ([xshift=-6em]neuron.west) {$x_1$:票价够低?}; \node [anchor=east] (x1) at ([xshift=-6em]neuron.west) {$x_1$:票价够低?};
\node [anchor=center] (x0) at ([yshift=3em]x1.center) {$x_0$:距离够近?}; \node [anchor=center] (x0) at ([yshift=3em]x1.center) {$x_0$:距离够近?};
\node [anchor=center] (x2) at ([yshift=-3em]x1.center) {$x_2$:女友一起}; \node [anchor=center] (x2) at ([yshift=-3em]x1.center) {$x_2$:女友喜欢};
\node [anchor=west] (y) at ([xshift=2em]neuron.east) {$y$:去不去?}; \node [anchor=west] (y) at ([xshift=2em]neuron.east) {$y$:去?还是不去?};
\visible<1>{ \visible<1>{
\draw [->,thick] (x0.east) -- (neuron.150) node [pos=0.5,above,yshift=0.2em] {\small{$w_0=1$}}; \draw [->,thick] (x0.east) -- (neuron.150) node [pos=0.5,above,yshift=0.2em] {\small{$w_0=1$}};
...@@ -420,17 +420,17 @@ y = f(w \cdot x + b) ...@@ -420,17 +420,17 @@ y = f(w \cdot x + b)
\end{frame} \end{frame}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
%%% 感知机 - 一个例子(cont2) %%% 感知机 - 一个例子:输入形式
\begin{frame}{一个例子(还在继续)} \begin{frame}{一个例子 - 输入形式}
\begin{itemize} \begin{itemize}
\item 在遭受了女友一万点伤害之后,你意识到决策不应该只考虑非0即1的因素,应该把"程度"考虑进来: \item 在遭受了女友一万点伤害之后,你意识到决策不应该只考虑非0即1的因素,应该把"程度"考虑进来:
\begin{itemize} \begin{itemize}
\item $x_0$:10/距离 \item $x_0$:10/距离
\item $x_1$:150/票价 \item $x_1$:150/票价
\item $x_2$:女朋友是否愿意一起?(这条不敢改) \item $x_2$:女朋友是否喜欢?(这条不敢改)
\end{itemize} \end{itemize}
\item<2-> 这时$x_0$$x_1$是连续变量,$x_2$是一个离散变量 \item<2-> 新模型中$x_0$$x_1$是连续变量,$x_2$是一个离散变量
\end{itemize} \end{itemize}
\visible<2->{ \visible<2->{
...@@ -470,8 +470,164 @@ y = f(w \cdot x + b) ...@@ -470,8 +470,164 @@ y = f(w \cdot x + b)
\begin{displaymath} \begin{displaymath}
\sum_i x_i \cdot w_i = 0.5 \cdot 0.5 + 0.3 \cdot 2 + 1 \cdot 0.5 = 1.35 \ge \sigma = 1 \sum_i x_i \cdot w_i = 0.5 \cdot 0.5 + 0.3 \cdot 2 + 1 \cdot 0.5 = 1.35 \ge \sigma = 1
\end{displaymath} \end{displaymath}
\end{itemize} \end{itemize}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
%%% 感知机 - 一个例子 - 学习
\begin{frame}{一个例子 - 学习}
\begin{itemize}
\item 一次成功的音乐会之后,你似乎掌握了真理:只要女朋友开心就好,为何不把这个因素的权重调大。最简单的方式是把$w_0$$w_1$的权重都置0,同时令$w_3 > 0$
\item<3-> 很快又有一场音乐会,距你1000公里,票价(不含路费)3000元,当然你女友是一直是喜欢音乐会的。根据新的决策模型,你义无反顾地\alert{决定去听}这场音乐会
\item<4-> \textbf{之后},你女朋友又给了你1万点伤害,痛啊!!!
\begin{itemize}
\item \alert{结果你发现}:女友既要浪漫,同时也爱财
\end{itemize}
\end{itemize}
\begin{center}
\begin{tikzpicture}
\begin{scope}
\node [anchor=center,circle,draw,ublue,very thick,minimum size=3.5em,fill=white,drop shadow] (neuron) at (0,0) {};
\node [anchor=east] (x1) at ([xshift=-6em]neuron.west) {$x_1$:便宜程度\ \ \ \ };
\node [anchor=center] (x0) at ([yshift=3em]x1.center) {$x_0$:远近程度\ \ \ \ };
\node [anchor=center] (x2) at ([yshift=-3em]x1.center) {$x_2$:女友喜欢?};
\node [anchor=west] (y) at ([xshift=2em]neuron.east) {$y$:去?还是不去?};
\draw [->,thick] (neuron.east) -- (y.west);
\node [anchor=center] (neuronmath) at (neuron.center) {\small{$\sum \ge \sigma$}};
\visible<1>{
\draw [->,thin] (x0.east) -- (neuron.150) node [pos=0.5,above,yshift=0.2em] {\small{$w_0=.5$}};
\draw [->,line width=0.8mm] (x1.east) -- (neuron.180) node [pos=0.5,above,yshift=-0.1em] {\textbf{\small{$w_1=2$}}};
\draw [->,thin] (x2.east) -- (neuron.210) node [pos=0.5,above,yshift=0.1em] {\small{$w_2=.5$}};
}
\visible<2->{
\draw [->,dotted] (x0.east) -- (neuron.150) node [pos=0.5,above,yshift=0.2em] {\small{$w_0=0$}};
\draw [->,dotted] (x1.east) -- (neuron.180) node [pos=0.5,above,yshift=-0.1em] {\textbf{\small{$w_1=0$}}};
\draw [->,line width=1mm] (x2.east) -- (neuron.210) node [pos=0.5,above,yshift=0.1em] {\small{$w_2=10$}};
}
\end{scope}
\end{tikzpicture}
\end{center}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
%%% 感知机 - 一个例子 - 学习(cont)
\begin{frame}{一个例子 - 权重学习}
\begin{itemize}
\item \textbf{痛定思痛},你发现每个因素的权重需要准确地设置才能达到最好的决策效果
\begin{itemize}
\item 如何确定最好的权重?
\end{itemize}
\item<2-> \textbf{当然},你是一个勇于实践的人
\begin{itemize}
\item 方法很简单:不断地尝试,根据结构不断地调整权重
\item<10-> 在进行了很多次实验后,发现了相对好的一组决策模型
\end{itemize}
\end{itemize}
\visible<2->{
\begin{center}
\begin{tikzpicture}
\begin{scope}[scale=0.6]
\visible<3->{
\draw [->,thick] (0,0) -- (2.5,0);
\draw [->,thick] (0,0) -- (0, 1.5);
\draw [-,very thick,ublue,domain=0.6:2,samples=100] plot (\x,{ 1/\x - 0.2});
\node [anchor=east] (ylabel) at (0, 3.2em) {\footnotesize{$x_0$}};
\node [anchor=north] (xlabel) at (5em, 0em) {\tiny{距离(km)}};
}
\visible<4->{
\draw [-,thick] (0.25,-1.5) -- (2.25,-1.5);
\node [anchor=east] (wlabel) at (0.25,-1.5) {\footnotesize{$w_0$}};
}
\visible<5>{\node [anchor=north,fill=ugreen,minimum height=0.5em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\visible<6>{\node [anchor=north,fill=ugreen,minimum height=0.3em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\visible<7>{\node [anchor=north,fill=ugreen,minimum height=1.8em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\visible<8>{\node [anchor=north,fill=ugreen,minimum height=0.3em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\visible<9>{\node [anchor=north,fill=ugreen,minimum height=0.3em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\visible<10->{\node [anchor=north,fill=ugreen,minimum height=0.8em,minimum width=1.5em] (w0) at (1.25,-1.5) {};}
\end{scope}
\begin{scope}[scale=0.6,xshift=12em]
\visible<3->{
\draw [->,thick] (0,0) -- (2.5,0);
\draw [->,thick] (0,0) -- (0, 1.5);
\draw [-,very thick,ublue,domain=0.4:2,samples=100] plot (\x,{ 0.5/\x});
\node [anchor=east] (ylabel) at (0, 3.2em) {\footnotesize{$x_1$}};
\node [anchor=north] (xlabel) at (5em, 0em) {\tiny{票价(元)}};
}
\visible<4->{
\draw [-,thick] (0.25,-1.5) -- (2.25,-1.5);
\node [anchor=east] (wlabel) at (0.25,-1.5) {\footnotesize{$w_1$}};
}
\visible<5>{\node [anchor=north,fill=ugreen,minimum height=0.5em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\visible<6>{\node [anchor=north,fill=ugreen,minimum height=1.5em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\visible<7>{\node [anchor=north,fill=ugreen,minimum height=0.8em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\visible<8>{\node [anchor=north,fill=ugreen,minimum height=0.1em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\visible<9>{\node [anchor=north,fill=ugreen,minimum height=1.0em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\visible<10->{\node [anchor=north,fill=ugreen,minimum height=0.3em,minimum width=1.5em] (w1) at (1.25,-1.5) {};}
\end{scope}
\begin{scope}[scale=0.6,xshift=24em]
\visible<3->{
\draw [->,thick] (0,0) -- (2.5,0);
\draw [->,thick] (0,0) -- (0, 1.5);
\node [anchor=east] (ylabel) at (0, 3.2em) {\footnotesize{$x_2$}};
\node [anchor=south, fill=ublue, minimum width=0.8em, minimum height=0.1em, inner sep=0] (histogram1) at (1.5em, 0) {};
\node [anchor=south, fill=ublue, minimum width=0.8em, minimum height=2em, inner sep=0] (histogram2) at (4.0em, 0) {};
\node [anchor=north,align=left] (hlabel1) at (histogram1.south) {\tiny{女友no}};
\node [anchor=north,align=left] (hlabel2) at ([xshift=0.5em]histogram2.south) {\tiny{女友yes}};
}
\visible<4->{
\draw [-,thick] (0.25,-1.5) -- (2.25,-1.5);
\node [anchor=east] (wlabel) at (0.25,-1.5) {\footnotesize{$w_2$}};
}
\visible<5>{\node [anchor=north,fill=ugreen,minimum height=0.5em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\visible<6>{\node [anchor=north,fill=ugreen,minimum height=1.2em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\visible<7>{\node [anchor=north,fill=ugreen,minimum height=0.8em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\visible<8>{\node [anchor=north,fill=ugreen,minimum height=1.2em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\visible<9>{\node [anchor=north,fill=ugreen,minimum height=1.5em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\visible<10->{\node [anchor=north,fill=ugreen,minimum height=1.3em,minimum width=1.5em] (w2) at (1.25,-1.5) {};}
\end{scope}
\end{tikzpicture}
\end{center}
}
\visible<5->{
\begin{center}
\begin{tabular}{c<{\onslide<5->}c<{\onslide<6->}c<{\onslide<7->}c<{\onslide<8->}c<{\onslide<9->}c<{\onslide<10->}c<{\onslide}}
实验 & 1 & 2 & 3 & 4 & ... & 10k \\
结果 & 失败 & 成功 & 失败 & 失败 & ... & 成功
\end{tabular}
\end{center}
}
\end{frame}
%%%------------------------------------------------------------------------------------------------------------
%%% 感知机 - 一个例子 - 总结
\begin{frame}{一个例子 - 总结}
\end{frame} \end{frame}
%%%------------------------------------------------------------------------------------------------------------ %%%------------------------------------------------------------------------------------------------------------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论