栈式自编码算法

From Ufldl

Jump to: navigation, search
(中英对照)
Line 107: Line 107:
一审@邓亚峰-人脸识别
一审@邓亚峰-人脸识别
终审@JerryLead
终审@JerryLead
-
 
-
===Overview===
 
-
 
-
The greedy layerwise approach for pretraining a deep network works by training each layer in turn. In this page, you will find out how autoencoders can be "stacked" in a greedy layerwise fashion for pretraining (initializing) the weights of a deep network.
 
-
 
-
【初译】
 
-
在深度神经网络进行预先训练的时候,有一种贪心分层方法,它的原理基于对每一个层次轮流进行训练。在本文中,我们会一起学习如何将上文中提到的自编码神经网络以栈的形式组成这种贪心分层的模样,从而预先训练(或者说初始化)深度神经网络的权重。
 
-
 
-
【一审】
 
-
可以采用依次训练每一层的贪心分层算法来预训练深度神经网络。在本节中,我们将会学习如何将自编码器以贪心分层的方式栈化,从而预训练(或者说初始化)深度神经网络的权重。
 
-
 
-
 
-
A stacked autoencoder is a neural network consisting of multiple layers of sparse autoencoders in which the outputs of each layer is wired to the inputs of the successive layer. Formally, consider a stacked autoencoder with n layers. Using notation from the autoencoder section, let <math>W^{(k, 1)}, W^{(k, 2)}, b^{(k, 1)}, b^{(k, 2)}</math> denote the parameters <math>W^{(1)}, W^{(2)}, b^{(1)}, b^{(2)}</math> for kth autoencoder. Then the encoding step for the stacked autoencoder is given by running the encoding step of each layer in forward order:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(l)} = f(z^{(l)}) \\
 
-
z^{(l + 1)} = W^{(l, 1)}a^{(l)} + b^{(l, 1)}
 
-
\end{align}
 
-
</math>
 
-
 
-
The decoding step is given by running the decoding stack of each autoencoder in reverse order:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(n + l)} = f(z^{(n + l)}) \\
 
-
z^{(n + l + 1)} = W^{(n - l, 2)}a^{(n + l)} + b^{(n - l, 2)}
 
-
\end{align}
 
-
</math>
 
-
 
-
The information of interest is contained within <math>a^{(n)}</math>, which is the activation of the deepest layer of hidden units. This vector gives us a representation of the input in terms of higher-order features.
 
-
 
-
【初译】
 
-
栈式自编码神经网络指的是这样一种网络,它由多层稀疏自编码神经网络组成,前一层网络的输出作为后一层的输入。形式化来讲,让我们来设想一个n层栈式自编码神经网络,并沿用自编码神经网络那章的各种符号,比如<math>W^{(k, 1)}, W^{(k, 2)}, b^{(k, 1)}, b^{(k, 2)}</math> 表示第k层网络里对应的<math>W^{(1)}, W^{(2)}, b^{(1)}, b^{(2)}</math> 参数。那么对于该栈式网络的编码过程就是,按照从前向后的顺序,执行每一层的编码过程:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(l)} = f(z^{(l)}) \\
 
-
z^{(l + 1)} = W^{(l, 1)}a^{(l)} + b^{(l, 1)}
 
-
\end{align}
 
-
</math>
 
-
 
-
解码就是从后向前每层解码咯:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(n + l)} = f(z^{(n + l)}) \\
 
-
z^{(n + l + 1)} = W^{(n - l, 2)}a^{(n + l)} + b^{(n - l, 2)}
 
-
\end{align}
 
-
</math>
 
-
 
-
在这里,我们感兴趣的信息是a(n),也就是最深的隐含单元层的激发阈值。这个向量对我们的输入给出更高层次的特征表示。
 
-
 
-
【一审】
 
-
栈式自编码神经网络是一个由多层稀疏自编码器组成的神经网络,其前一层自编码器的输出作为其后一层自编码器的输入。形式上,对于一个n层栈式自编码神经网络而言,沿用自编码器一章的各种符号,假定用<math>W^{(k, 1)}, W^{(k, 2)}, b^{(k, 1)}, b^{(k, 2)}</math> 表示第k个自编码器对应的<math>W^{(1)}, W^{(2)}, b^{(1)}, b^{(2)}</math> 参数,那么该栈式自编码神经网络的编码过程就是依照从前向后的顺序执行每一层自编码器的编码步骤:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(l)} = f(z^{(l)}) \\
 
-
z^{(l + 1)} = W^{(l, 1)}a^{(l)} + b^{(l, 1)}
 
-
\end{align}
 
-
</math>
 
-
 
-
同理,栈式神经网络的解码过程就是依照从后向前的顺序执行每一层自编码器的解码步骤:
 
-
 
-
<math>
 
-
\begin{align}
 
-
a^{(n + l)} = f(z^{(n + l)}) \\
 
-
z^{(n + l + 1)} = W^{(n - l, 2)}a^{(n + l)} + b^{(n - l, 2)}
 
-
\end{align}
 
-
</math>
 
-
 
-
其中,a(n)是隐藏单元最深层的响应,其包含了我们感兴趣的信息,这个向量是对输入的更高阶的表示。
 
-
 
-
The features from the stacked autoencoder can be used for classification problems by feeding <math>a(n)</math> to a softmax classifier.
 
-
 
-
【初译】
 
-
从栈式自编码神经网络中学到的特征,可以通过向softmax分类器添加 <math>a(n)</math>的方式来解决分类问题。
 
-
 
-
【一审】
 
-
通过将 <math>a(n)</math>作为softmax分类器的输入特征,可以将栈式自编码神经网络中学到的特征用于分类问题。
 
-
 
-
 
-
===Training===
 
-
A good way to obtain good parameters for a stacked autoencoder is to use greedy layer-wise training. To do this, first train the first layer on raw input to obtain parameters <math>W^{(1,1)}, W^{(1,2)}, b^{(1,1)}, b^{(1,2)}</math>. Use the first layer to transform the raw input into a vector consisting of activation of the hidden units, A. Train the second layer on this vector to obtain parameters <math>W^{(2,1)}, W^{(2,2)}, b^{(2,1)}, b^{(2,2)}</math>. Repeat for subsequent layers, using the output of each layer as input for the subsequent layer.
 
-
 
-
【初译】
 
-
想从上述栈式网络中得到好的参数,我们可以使用贪心分层方法。即先通过输入来训练第一层网络,得到<math>W^{(1,1)}, W^{(1,2)}, b^{(1,1)}, b^{(1,2)}</math>。再用第一层网络将输入转化,成为由隐藏单元的激发阈值组成的向量,暂且称做A。把A作为第二层的输入,继续进行训练,得到<math>W^{(2,1)}, W^{(2,2)}, b^{(2,1)}, b^{(2,2)}</math>。如此这般,都是前一层的输出作为后一层的输入。
 
-
 
-
【一审】
 
-
一种比较好的获取栈式自编码神经网络参数的方法是采用贪心分层方式进行训练。即先通过原始输入来训练第一层网络,得到其参数<math>W^{(1,1)}, W^{(1,2)}, b^{(1,1)}, b^{(1,2)}</math>;再用第一层网络将原始输入转化成为由隐藏单元响应组成的向量,假设该向量为A,接着把A作为第二层的输入,继续训练得到第二层的参数<math>W^{(2,1)}, W^{(2,2)}, b^{(2,1)}, b^{(2,2)}</math>;对后面的各层同样采用将前层的输出作为下一层输入的方式依次训练。
 
-
 
-
 
-
This method trains the parameters of each layer individually while freezing parameters for the remainder of the model. To produce better results, after this phase of training is complete, [[Fine-tuning Stacked AEs | fine-tuning]] using backpropagation can be used to improve the results by tuning the parameters of all layers are changed at the same time.
 
-
 
-
【初译】
 
-
这种方法在训练的时候,除了当前层,不会改变其他层次的参数。因此,为了得到更好的结果,在训练阶段结束以后,用反向传播算法微调一下,让所有层的参数同时变化,会对结果有所提升。
 
-
 
-
【一审】
 
-
上述训练方式,在训练每一层参数的时候,会固定其它各层参数保持不变。所以,如果想得到更好的结果,在上述预训练过程完成之后,可以通过反向传播算法同时调整所有层的参数以改善结果,这个过程一般被称作“微调(fine-tuning)”。
 
-
 
-
 
-
<!-- In practice, fine-tuning should be use when the parameters have been brought close to convergence through layer-wise training. Attempting to use fine-tuning with the weights initialized randomly will lead to poor results due to local optima. -->
 
-
 
-
{{Quote|
 
-
If one is only interested in finetuning for the purposes of classification, the common practice is to then discard the "decoding" layers of the stacked autoencoder and link the last hidden layer <math>a^{(n)}</math> to the softmax classifier. The gradients from the (softmax) classification error will then be backpropagated into the encoding layers.
 
-
 
-
 
-
【初译】
 
-
如果你只对分类神经网络的微调感兴趣,惯用的做法是丢掉栈式网络的“解码”层,直接把最后那个隐含层<math>a^{(n)}</math> 跟softmax分类器连起来。这样分类器错误的梯度值就会直接反向传播给编码层了。
 
-
 
-
【一审】
 
-
注:如果你只对以分类为目的的微调感兴趣,惯用的做法是丢掉栈式自编码器网络的“解码”层,直接把最后一个隐含层的<math>a^{(n)}</math> 作为特征输入到softmax分类器进行分类,这样,分类器(softmax)的分类错误的梯度值就可以直接反向传播给编码层了。
 
-
 
-
}}
 
-
 
-
===Concrete example===
 
-
 
-
To give a concrete example, suppose you wished to train a stacked autoencoder with 2 hidden layers for classification of MNIST digits, as you will be doing in [[Exercise: Implement deep networks for digit classification | the next exercise]].
 
-
 
-
First, you would train a sparse autoencoder on the raw inputs <math>x^{(k)}</math> to learn primary features <math>h^{(1)(k)}</math> on the raw input.
 
-
 
-
【初译】
 
-
 真实的故事..
 
-
咱们来看个具体例子,假设你想要训练一个有两个隐含层的栈式网络,用来对MNIST数字集分类。别急,这是你的下一个练习。
 
-
首先,你需要训练一个自编码网络,它用输入<math>x^{(k)}</math>  来学到最基本的特征表示 <math>h^{(1)(k)}</math>。
 
-
 
-
【一审】
 
-
 具体实例
 
-
让我们来看个具体的例子,假设你想要训练一个包含两个隐含层的栈式自编码网络用于MNIST数字分类(这将会是你的下一个练习)。
 
-
首先,你需要用原始输入<math>x^{(k)}</math> 训练第一个自编码器,它能够学习得到原始输入的一阶特征表示<math>h^{(1)(k)}</math>(如下图所示)。
 
-
 
-
 
-
[[File:Stacked_SparseAE_Features1.png|400px]]
 
-
 
-
Next, you would feed the raw input into this trained sparse autoencoder, obtaining the primary feature activations <math>h^{(1)(k)}</math> for each of the inputs <math>x^{(k)}</math>. You would then use these primary features as the "raw input" to another sparse autoencoder to learn secondary features <math>h^{(2)(k)}</math> on these primary features.
 
-
 
-
【初译】
 
-
接着,你需要把原始数据输入到训练好的稀疏网络中,对于每一个<math>x^{(k)}</math>,得到它对应的基础特征表示<math>h^{(2)(k)}</math>。然后你再用这些特征作为另一个稀疏网络的输入,在它们的基础上,来学习第二层特征。
 
-
 
-
 
-
【一审】
 
-
接着,你需要把原始数据输入到上述训练好的稀疏自编码器中,对于每一个输入<math>x^{(k)}</math>,都可以得到它对应的一阶特征表示<math>h^{(2)(k)}</math>。然后你再用这些一阶特征作为另一个稀疏自编码器的输入,使用它们来学习二阶特征。(如下图所示)
 
-
 
-
[[File:Stacked_SparseAE_Features2.png|400px]]
 
-
 
-
Following this, you would feed the primary features into the second sparse autoencoder to obtain the secondary feature activations <math>h^{(2)(k)}</math> for each of the primary features <math>h^{(1)(k)}</math> (which correspond to the primary features of the corresponding inputs <math>x^{(k)}</math>). You would then treat these secondary features as "raw input" to a softmax classifier, training it to map secondary features to digit labels.
 
-
 
-
【初译】
 
-
照这样,再把基础特征输入到刚训练好的第二层稀疏网络中,得到对应每个<math>h^{(1)(k)}</math>的更高层表示<math>h^{(2)(k)}</math>。现在你可以把这些二级特征作为softmax分类器的输入了,训练之,完成从特征到数字标签的匹配。
 
-
 
-
【一审】
 
-
同样,再把一阶特征输入到刚训练好的第二层稀疏自编码器中,得到每个<math>h^{(1)(k)}</math>对应的二阶特征响应<math>h^{(2)(k)}</math>。接下来,你可以把这些二阶特征作为softmax分类器的输入,训练得到一个将二阶特征映射到数字标签的模型。
 
-
 
-
[[File:Stacked_Softmax_Classifier.png|400px]]
 
-
 
-
Finally, you would combine all three layers together to form a stacked autoencoder with 2 hidden layers and a final softmax classifier layer capable of classifying the MNIST digits as desired.
 
-
 
-
【初译】
 
-
最终,你需要把这三层一起组成一个栈式网络,它有两个隐藏层,一个最终的分类器。这个网络会如你所愿的把MNIST数字集分类。
 
-
 
-
【一审】
 
-
如下图所示,最终,你可以将这三层结合起来构建一个包含两个隐藏层和一个最终softmax分类器层的栈式自编码网络,这个网络能够如你所愿的对MNIST数字进行分类。
 
-
 
-
[[File:Stacked_Combined.png|500px]]
 
-
 
-
===Discussion===
 
-
 
-
A stacked autoencoder enjoys all the benefits of any deep network of greater expressive power. 
 
-
 
-
Further, it often captures a useful "hierarchical grouping" or "part-whole decomposition" of the input.  To see this, recall that an autoencoder tends to learn features that form a good representation of its input. The first layer of a stacked autoencoder tends to learn first-order features in the raw input (such as edges in an image). The second layer of a stacked autoencoder tends to learn second-order features corresponding to patterns in the appearance of first-order features (e.g., in terms of what edges tend to occur together--for example, to form contour or corner detectors). Higher layers of the stacked autoencoder tend to learn even higher-order features.
 
-
 
-
【初译】
 
-
栈式自编码神经网络,包容了任何有表现力的深度网络的全部优点(广告词)。更进一步,它还常常会捕获输入中一些有用的现象,如“层次分组”或者“部分-整体分解”。为啥这样说呢?回顾一下,所有的自编码网络都倾向于学习能更好的表示输入数据的特征。栈式网络的第一层会学好最基础的特征,(比如图片里的边缘)。第二层会学好二级特征,对应基础特征中的各种模式(比如什么样的边缘通常会扎堆出现—例如形成连通域的或者角点的)。栈式网络的更高层还会学到更高层次的特征。
 
-
 
-
【一审】
 
-
栈式自编码神经网络具有任何有着强大表示能力的深度神经网络的所有优点。
 
-
更进一步,它通常能够获取到输入的“层次型分组”或者“部分-整体分解”结构。为了弄清这一点,回顾一下,自编码器倾向于学习得到能更好地表示输入数据的特征。因此,栈式自编码神经网络的第一层会学习得到原始输入的一阶特征(比如图片里的边缘),第二层会学习得到二阶特征,其对应一阶特征的呈现模式(比如在构成轮廓或者角点时,什么样的边缘会共现)。栈式自编码神经网络的更高层还会学到更高阶的特征。
 
-
 
-
中英对照:
 
-
 
-
【初译】
 
-
 
-
 
-
【一审】
 
-
自编码器(Autoencoder)
 
-
预训练(PreTrain)
 
-
栈式自编码神经网络(stacked autoencoder)
 
-
微调(fine-tuning)
 
-
原始输入(raw inputs)
 
-
层次型分组(hierarchical grouping)
 
-
部分-整体分解(part-whole decomposition)
 
-
一阶特征(first-order features)
 
-
二阶特征(second-order features)
 
-
更高阶特征(higher-order features)
 
-
 
-
 
-
{{CNN}}
 
-
 
-
<!--
 
-
For instance, in the context of image input, the first layers usually learns to recognize edges. The second layer usually learns features that arise from combinations of the edges, such as corners. With certain types of network configuration and input modes, the higher layers can learn meaningful combinations of features. For instance, if the input set consists of images of faces, higher layers may learn features corresponding to parts of the face such as eyes, noses or mouths.
 
-
!-->
 

Revision as of 11:30, 30 March 2013

Personal tools