Luozm +

机器学习课程笔记-4

Notes about Andrew Ng's Machine Learning course on Coursera-part 4

原创文章,转载请注明:转自Luozm's Blog

1. Neural Networks–representation

1.1 Motivations

1.2 Model Representation

At a very simple level, neurons are basically computational units that take inputs (dendrites) as electrical inputs (called “spikes”) that are channeled to outputs (axons). In our model, our dendrites are like the input features $x_1⋯x_n$, and the output is the result of our hypothesis function. In this model our $x_0$ input node is sometimes called the “bias unit.” It is always equal to 1. In neural networks, we use the same logistic function as in classification, $\frac{1}{1+e^{−θ^Tx}}$, yet we sometimes call it a sigmoid (logistic) activation function. In this situation, our “theta” parameters are sometimes called “weights”.

一个简单的神经网络表示如下:

其中第一层是输入层,中间括号中为隐含层,最终输出一个假设函数,也就是输出层。

含有一个隐含层的模型如下:

其中

If network has $s_j$ units in layer $j$ and $s_{j+1}$ units in layer $j+1$, then $\Theta^{(j)}$ will be of dimension $s_{j+1} \times (s_j + 1)$.

model Representation

Vectorized Version

重新整理上述模型:

其中,对于层 $j=2$ 和节点 $k$ ,变量 $z$ 表示为:

向量化 $x$ 和 $z$,如下:

令 $x = a^{(1)}$,则向量化后的公式可以重写为:

注意在最后一层中,我们做的事情与逻辑回归中相同:

1.3 Applications

模拟 “AND”

我们所用的模型如下:

当且仅当 $x_1$ 和 $x_2$ 都为1时输出1,结果如下:

模拟”OR”

模型与上述类似,只是权重有所改变:

结果如下: OR

模拟其他逻辑操作

总结起来,模拟不同操作的参数如下:

“XNOR”: 结合上述参数来模拟”XNOR”(which gives 1 if $x_1$ and $x_2$ are both 0 or both 1):

其中,第一层的参数结合了”AND”和”NOR”:

第二层的参数与”OR”相同:

具体模型如下:

XNOR

Multiclass Classification

为了完成多类分类任务,我们采用“one VS all”策略,即同时对每个类别进行逻辑回归: Multiclass

定义标签 $y$ 为: y

同时预测多个类别:

hx

输出结果可能如下,这表示预测分类为Motorcycle:

© Luozm . All rights reserved. | Top

Life

Theory

Develop