Browse Source

finish week4

master
scruel 7 years ago
parent
commit
6f00e286f2
10 changed files with 72 additions and 21 deletions
  1. BIN
      image/20180116_235545.png
  2. BIN
      image/20180117_000349.png
  3. BIN
      image/20180117_000612.png
  4. BIN
      image/20180117_004820.png
  5. BIN
      image/20180117_010904.png
  6. BIN
      image/20180117_011331.png
  7. +11
    -11
      week3.html
  8. +1
    -1
      week3.md
  9. +1
    -1
      week4.html
  10. +59
    -8
      week4.md

BIN
image/20180116_235545.png View File

Before After
Width: 880  |  Height: 282  |  Size: 54 kB

BIN
image/20180117_000349.png View File

Before After
Width: 841  |  Height: 232  |  Size: 35 kB

BIN
image/20180117_000612.png View File

Before After
Width: 863  |  Height: 256  |  Size: 35 kB

BIN
image/20180117_004820.png View File

Before After
Width: 893  |  Height: 221  |  Size: 48 kB

BIN
image/20180117_010904.png View File

Before After
Width: 786  |  Height: 323  |  Size: 205 kB

BIN
image/20180117_011331.png View File

Before After
Width: 560  |  Height: 132  |  Size: 12 kB

+ 11
- 11
week3.html
File diff suppressed because it is too large
View File


+ 1
- 1
week3.md View File

@@ -72,7 +72,7 @@ $\begin{align*}& h_\theta(x) = P(y=1 | x ; \theta) = 1 - P(y=0 | x ; \theta) \ne

$\begin{align*}& h_\theta(x) \geq 0.5 \rightarrow y = 1 \newline& h_\theta(x) < 0.5 \rightarrow y = 0 \newline\end{align*}$

回忆一下逻辑函数的图像:
回忆一下 sigmoid 函数的图像:

![sigmoid function](image/2413fbec8ff9fa1f19aaf78265b8a33b_Logistic_function.png)



+ 1
- 1
week4.html
File diff suppressed because it is too large
View File


+ 59
- 8
week4.md View File

@@ -74,14 +74,12 @@ BrainPort 系统:帮助失明人士通过摄像头以及舌尖感官“看”

依据本节所给模型,有:

$Size(\Theta^{(1)})=s_{j+1} \times (s_j + 1) = 3 \times 4$
$Size(\Theta^{(1)})=s_{j+1} \times (s_j + 1) =s_2 \times (s_1 + 1) = 3 \times 4$

$Size(\Theta^{(2)})=s_{j+1} \times (s_j + 1) = 1 \times 4$
$Size(\Theta^{(2)})=s_3 \times (s_2 + 1) = 1 \times 4$

## 8.4 模型表示2(Model Representation II)

> 神经网络中的符号较多,易乱,建议多看几遍多回顾。

![](image/20180116_001543.png)

对第 $1$ 层的所有激活单元应用激活函数,从而得到第 $2$ 层激活单元的值:
@@ -100,9 +98,7 @@ $h_\Theta(x) = a_1^{(3)} = g(\Theta_{10}^{(2)}a_0^{(2)} + \Theta_{11}^{(2)}a_1^{

${h_\theta}\left( x \right)=g\left( {\theta_0}+{\theta_1}{x_1}+{\theta_{2}}{x_{2}}+{\theta_{3}}x_{1}^{2} \right)$

是不是除了符号表示,其他都完全一样?其实神经网络就好似回归模型,只不过输入变成了中间单元 $a_1^{(j)}, a_2^{(j)}, \dots, a_n^{(j)}$。中间单元从输入向量 $x$ 开始,下一层的每个单元对所有输入的信息通过最优化算法不断迭代计算,每个单元因为包含了前一层的所有单元值,那么每个单元都能依赖于权重与输入得出关于输入向量的更多信息,就好像是在给假设函数加多项式。

中间单元就好像是包含了更多信息的升级版输入参数,使用包含更多信息的中间单元,也能产生更好地预测。
是不是除了符号表示,其他都完全一样?其实神经网络就好似回归模型,只不过输入变成了中间单元 $a_1^{(j)}, a_2^{(j)}, \dots, a_n^{(j)}$。从输入 $x$ 开始,下一层的每个激活单元都包含了上一层的所有信息(单元值),通过最优化算法不断迭代计算,激活单元能得出关于输入 $x$ 的更多信息,这就好像是在给假设函数加多项式。中间层的这些单元好似升级版的初始特征,从而能给出更好的预测。



@@ -140,6 +136,61 @@ ${{z}^{\left( 2 \right)}}={{\Theta }^{\left( 1 \right)}} {{X}^{T}}$,这时 $z^

## 8.5 例子和直观理解1(Examples and Intuitions I)

为了更好的理解神经网络,举例单层神经网络进行逻辑运算的例子。

下面的例子中,$x_1,x_2$ 为二进制数。

逻辑与(AND)运算(都为真值则结果才为真)神经网络:

![](image/20180117_000612.png)

$\Theta^{(1)} =\begin{bmatrix}-30 & 20 & 20\end{bmatrix}$,$h_\Theta(x) = g(-30+20x_1+20x_2)$。

回顾 sigmoid 函数图像,根据输入则有上图中右边的表格,即 $h_\theta(x)\approx x_1\ \text{AND}\ x_2$。这样就实现了一个能够进行与运算的神经网络。

![sigmoid function](image/2413fbec8ff9fa1f19aaf78265b8a33b_Logistic_function.png)



再举一例,逻辑或(OR)运算(有一个真值则结果就为真)神经网络:

![](image/20180117_000349.png)



## 8.6 例子和直观理解2(Examples and Intuitions II)

## 8.7 多类别分类(Multiclass Classification)
下面逐步构建复杂一点的神经网络

![](image/20180117_004820.png)

如上图,我们分别构建了三个单层神经网络,将这三个网络组合起来,可得到一个新的神经网络,其可完成逻辑运算中的异或(XNOR)操作:

![](image/20180116_235545.png)

这里的组合即为 $\text{XNOR}=( \text{x}_1\, \text{AND}\, \text{x}_2 )\, \text{OR} \left( \left( \text{NOT}\, \text{x}_1 \right) \text{AND} \left( \text{NOT}\, \text{x}_2 \right) \right)$

$\Theta^{(1)} =\begin{bmatrix}-30 & 20 & 20 \newline 10 & -20 & -20\end{bmatrix}$,$\Theta^{(2)} =\begin{bmatrix}-10 & 20 & 20\end{bmatrix}$,$\begin{align*}& a^{(2)} = g(\Theta^{(1)} \cdot x) \newline& a^{(3)} = g(\Theta^{(2)} \cdot a^{(2)}) \newline& h_\Theta(x) = a^{(3)}\end{align*}$

可见,特征值能不断升级,并抽取出更多信息,直到计算出结果。而如此不断组合,我们就可以逐渐构造出越来越复杂、强大的神经网络,比如用于手写识别的神经网络。

## 8.7 多类别分类(Multiclass Classification)

之前讨论的都是预测结果为单值情况下的神经网络,要实现多类别分类,其实只要修改一下输出层,让输出层包含多个输出单元即可。

举一个 4 分类问题的实例:

![](image/20180117_010904.png)

有四种分类情况,那么就让输出层包含 4 个输出单元即可,则 $h_\Theta$ 为 4 维向量。

神经网络中的多分类算法算是对 one-vs-all 思想的扩展,定义预测结果一共有 4 种情况:

![](image/20180117_011331.png)

如果预测结果 $h_\Theta(x) =\begin{bmatrix}0 \newline 0 \newline 1 \newline 0 \newline\end{bmatrix}$,

那么表示 $h_\Theta(x)_3$,即分为第 3 类,对应于图中的摩托车(Motorcycle)。

**总结一下**,要分为 $k$ 类,就在输出层放置 $k$ 个输出单元,对于单个样本实例,$h_\Theta(x)$ 则是一个 $k$ 维结果向量,最后依据结果向量,得出属于哪个类 $y^{(i)}$。


Loading…
Cancel
Save