神经网络
From Ufldl
(→概述) |
|||
Line 1: | Line 1: | ||
==概述== | ==概述== | ||
+ | |||
以监督学习为例,假设我们有训练样本集 <math>\textstyle (x(^ i),y(^ i))</math> ,那么神经网络算法能够提供一种复杂且非线性的假设模型 <math>\textstyle h_{W,b}(x)</math> ,它具有参数 <math>\textstyle W, b</math> ,可以以此参数来拟合我们的数据。 | 以监督学习为例,假设我们有训练样本集 <math>\textstyle (x(^ i),y(^ i))</math> ,那么神经网络算法能够提供一种复杂且非线性的假设模型 <math>\textstyle h_{W,b}(x)</math> ,它具有参数 <math>\textstyle W, b</math> ,可以以此参数来拟合我们的数据。 | ||
Line 38: | Line 39: | ||
最后要说明的是,有一个等式我们以后会经常用到:如果选择 <math>\textstyle f(z) = 1/(1+\exp(-z))</math> ,也就是sigmoid函数,那么它的导数就是 <math>\textstyle f'(z) = f(z) (1-f(z))</math> (如果选择tanh函数,那它的导数就是 <math>\textstyle f'(z) = 1- (f(z))^2</math> ,你可以根据sigmoid(或tanh)函数的定义自行推导这个等式。 | 最后要说明的是,有一个等式我们以后会经常用到:如果选择 <math>\textstyle f(z) = 1/(1+\exp(-z))</math> ,也就是sigmoid函数,那么它的导数就是 <math>\textstyle f'(z) = f(z) (1-f(z))</math> (如果选择tanh函数,那它的导数就是 <math>\textstyle f'(z) = 1- (f(z))^2</math> ,你可以根据sigmoid(或tanh)函数的定义自行推导这个等式。 | ||
+ | |||
==神经网络模型== | ==神经网络模型== | ||
Line 48: | Line 50: | ||
- | 我们用 <math>\textstyle {n}_l</math> 来表示网络的层数,本例中 <math>\textstyle n_l=3</math> ,我们将第 <math>\textstyle l</math> 层记为 <math>\textstyle L_l</math> ,于是 <math>\textstyle L_1</math> 是输入层,输出层是 <math>\textstyle L_{n_l}</math> 。本例神经网络有参数 <math>\textstyle (W,b) = (W^{(1)}, b^{(1)}, W^{(2)}, b^{(2)})</math> ,其中 <math>\textstyle W^{(l)}_{ij}</math> | + | 我们用 <math>\textstyle {n}_l</math> 来表示网络的层数,本例中 <math>\textstyle n_l=3</math> ,我们将第 <math>\textstyle l</math> 层记为 <math>\textstyle L_l</math> ,于是 <math>\textstyle L_1</math> 是输入层,输出层是 <math>\textstyle L_{n_l}</math> 。本例神经网络有参数 <math>\textstyle (W,b) = (W^{(1)}, b^{(1)}, W^{(2)}, b^{(2)})</math> ,其中 <math>\textstyle W^{(l)}_{ij}</math> (下面的式子中用到)是第 <math>\textstyle l</math> 层第 <math>\textstyle j</math> 单元与第 <math>\textstyle l+1</math> 层第 <math>\textstyle i</math> 单元之间的联接参数(其实就是连接线上的权重,注意标号顺序), <math>\textstyle b^{(l)}_i</math> 是第 <math>\textstyle l+1</math> 层第 <math>\textstyle i</math> 单元的偏置项。因此在本例中, <math>\textstyle W^{(1)} \in \Re^{3\times 3}</math> , <math>\textstyle W^{(2)} \in \Re^{1\times 3}</math> 。注意,没有其他单元连向偏置单元(即偏置单元没有输入),因为它们总是输出 <math>\textstyle +1</math>。同时,我们用 <math>\textstyle s_l</math> 表示第 <math>\textstyle l</math> 层的节点数(偏置单元不计在内)。 |
我们用 <math>\textstyle a^{(l)}_i</math> 表示第 <math>\textstyle l</math> 层第 <math>\textstyle i</math> 单元的'''激活值'''(输出值)。当 <math>\textstyle l=1</math> 时, <math>\textstyle a^{(1)}_i = x_i</math> ,也就是第 <math>\textstyle i</math> 个输入值(输入值的第 <math>\textstyle i</math> 个特征)。对于给定参数集合 <math>\textstyle W,b</math> ,我们的神经网络就可以按照函数 <math>\textstyle h_{W,b}(x)</math> 来计算输出结果。本例神经网络的计算步骤如下: | 我们用 <math>\textstyle a^{(l)}_i</math> 表示第 <math>\textstyle l</math> 层第 <math>\textstyle i</math> 单元的'''激活值'''(输出值)。当 <math>\textstyle l=1</math> 时, <math>\textstyle a^{(1)}_i = x_i</math> ,也就是第 <math>\textstyle i</math> 个输入值(输入值的第 <math>\textstyle i</math> 个特征)。对于给定参数集合 <math>\textstyle W,b</math> ,我们的神经网络就可以按照函数 <math>\textstyle h_{W,b}(x)</math> 来计算输出结果。本例神经网络的计算步骤如下: | ||
+ | |||
:<math> | :<math> | ||
Line 61: | Line 64: | ||
\end{align} | \end{align} | ||
</math> | </math> | ||
+ | |||
我们用 <math>\textstyle z^{(l)}_i</math> 表示第 <math>\textstyle l</math> 层第 <math>\textstyle i</math> 单元输入加权和(包括偏置单元),比如, <math>\textstyle z_i^{(2)} = \sum_{j=1}^n W^{(1)}_{ij} x_j + b^{(1)}_i</math> ,则 <math>\textstyle a^{(l)}_i = f(z^{(l)}_i)</math> 。 | 我们用 <math>\textstyle z^{(l)}_i</math> 表示第 <math>\textstyle l</math> 层第 <math>\textstyle i</math> 单元输入加权和(包括偏置单元),比如, <math>\textstyle z_i^{(2)} = \sum_{j=1}^n W^{(1)}_{ij} x_j + b^{(1)}_i</math> ,则 <math>\textstyle a^{(l)}_i = f(z^{(l)}_i)</math> 。 | ||
Line 66: | Line 70: | ||
这样我们就可以得到一种更简洁的表示法。这里我们将激活函数 <math>\textstyle f(\cdot)</math> 扩展为用向量(分量的形式)来表示,即 <math>\textstyle f([z_1, z_2, z_3]) = [f(z_1), f(z_2), f(z_3)]</math> ,那么,上面的等式可以更简洁地表示为: | 这样我们就可以得到一种更简洁的表示法。这里我们将激活函数 <math>\textstyle f(\cdot)</math> 扩展为用向量(分量的形式)来表示,即 <math>\textstyle f([z_1, z_2, z_3]) = [f(z_1), f(z_2), f(z_3)]</math> ,那么,上面的等式可以更简洁地表示为: | ||
+ | |||
:<math>\begin{align} | :<math>\begin{align} | ||
Line 73: | Line 78: | ||
h_{W,b}(x) &= a^{(3)} = f(z^{(3)}) | h_{W,b}(x) &= a^{(3)} = f(z^{(3)}) | ||
\end{align}</math> | \end{align}</math> | ||
+ | |||
我们将上面的计算步骤叫作'''前向传播'''。回想一下,之前我们用 <math>\textstyle a^{(1)} = x</math> 表示输入层的激活值,那么给定第 <math>\textstyle l</math> 层的激活值 <math>\textstyle a^{(l)}</math> 后,第 <math>\textstyle l+1</math> 层的激活值 <math>\textstyle a^{(l+1)}</math> 就可以按照下面步骤计算得到: | 我们将上面的计算步骤叫作'''前向传播'''。回想一下,之前我们用 <math>\textstyle a^{(1)} = x</math> 表示输入层的激活值,那么给定第 <math>\textstyle l</math> 层的激活值 <math>\textstyle a^{(l)}</math> 后,第 <math>\textstyle l+1</math> 层的激活值 <math>\textstyle a^{(l+1)}</math> 就可以按照下面步骤计算得到: | ||
+ | |||
:<math> \begin{align} | :<math> \begin{align} | ||
Line 89: | Line 96: | ||
神经网络也可以有多个输出单元。比如,下面的神经网络有两层隐藏层: <math>\textstyle L_2</math> 及 <math>\textstyle L_3</math> ,输出层 <math>\textstyle L_4</math> 有两个输出单元。 | 神经网络也可以有多个输出单元。比如,下面的神经网络有两层隐藏层: <math>\textstyle L_2</math> 及 <math>\textstyle L_3</math> ,输出层 <math>\textstyle L_4</math> 有两个输出单元。 | ||
+ | |||
[[Image:Network3322.png|500px|center]] | [[Image:Network3322.png|500px|center]] | ||
+ | |||
要求解这样的神经网络,需要样本集 <math>\textstyle (x^{(i)}, y^{(i)})</math> ,其中 <math>\textstyle y^{(i)} \in \Re^2</math> 。如果你想预测的输出是多个的,那这种神经网络很适用。(比如,在医疗诊断应用中,患者的体征指标就可以作为向量的输入值,而不同的输出值 <math>\textstyle y_i</math> 可以表示不同的疾病存在与否。) | 要求解这样的神经网络,需要样本集 <math>\textstyle (x^{(i)}, y^{(i)})</math> ,其中 <math>\textstyle y^{(i)} \in \Re^2</math> 。如果你想预测的输出是多个的,那这种神经网络很适用。(比如,在医疗诊断应用中,患者的体征指标就可以作为向量的输入值,而不同的输出值 <math>\textstyle y_i</math> 可以表示不同的疾病存在与否。) | ||
Line 114: | Line 123: | ||
==中文译者== | ==中文译者== | ||
- | @ | + | 孙逊(sunpaofu@foxmail.com),林锋(xlfg@yeah.net),刘鸿鹏飞(just.dark@foxmail.com), 许利杰(csxulijie@gmail.com) |
+ | |||
+ | |||
+ | {{稀疏自编码器}} | ||
+ | |||
+ | |||
+ | {{Languages|Neural_Networks|English}} |