斯坦福机器学习第四周(神经网络及其应用)
1.为什么要引入神经网络(Neural Network)
一句话总结就是当特征值n特别大时,比如当n为100时;仅仅是其2次项特征值
2.神经网络模型(Neural Network Model)
Let’s examine how we will represent a hypothesis function using neural networks. 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
x1…xn , and the output is the result of our hypothesis function. In this model ourx0 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,11+e−θTx , yet we sometimes call it a sigmoid (logistic) activation function. In this situation, our “theta” parameters are sometimes called “weights“.
如图就是一个只包含一个神经元的模型,黄色圆圈为神经元细胞(cell body),
而真正的神经网络是若干个这样不同的神经元组合而成的,如下图
其中
3.神经网络的数学定义(Mathematical definition)
比如一个
The values for each of the “activation” nodes is obtained as follows:
This is saying that we compute our activation nodes by using a 3×4 matrix of parameters. We apply each row of the parameters to our inputs to obtain the value for one activation node. Our hypothesis output is the logistic function applied to the sum of the values of our activation nodes, which have been multiplied by yet another parameter matrix
Θ(2) containing the weights for our second layer of nodes.
因此我们可以看出,其实每一个活化单元的值都是以上一层作为输入,以上一层的权重矩阵的对应一行为参数,然后进行关于函数
Each layer gets its own matrix of weights,
Θ(j) . The dimensions of these matrices of weights is determined as follows:If network has
sj units in layerj andsj+1 units in layerj+1 , thenΘ(j) will be of dimensionsj+1×(sj+1) .
4.矢量化(Vectorized implementation)
先做出如下定义:
令:
setting
总结一下
重复进行(1)(2),然后可以发现最后一层的活化单元(activation unit)的值就是
5.Examples and Intuitions
用神经网络实现逻辑门(Logical gate)
例1.与门(And gate)
Remember that
x0 is our bias variable and is always 1.
Let’s set our first theta matrix as:
This will cause the output of our hypothesis to only be positive if both
x1 andx2 are 1. In other words:
例2.同或门(And gate)
Layer 2:
Layer 3: