1. 从 PCA 开始
使用PCA对数据进行降维和重构的过程大致上如下图所示
首先将输入的数据乘以一个矩阵得到降维之后的结果,之后再将降维之后的数据乘以之前权重矩阵的转置,恢复得到近似的原始图像。在这个过程中,我们希望输入层与输出层的图像之间越相似越好。这个过程也已通过NN的方式实现,其中 Input layer 到 hidden layer 的过程是编码(encode)过程,而从 hidden layer 到 Output layer 的过程是解码的过程(decode)。因为 hidden layer 得到的结果往往会比原始的维数小,就像一个瓶子的瓶颈一样狭窄,所以也将 hidden layer 称为 bottleneck layer 。
一个很自然的深度自编码器的想法是如下所示的过程
其中有两点需要注意,首先这里认为前后的权重矩阵是对称的,然而不是对称的也没过关系,因为用的是NN的方法而不是PCA的方法,不必满足前后的对称慈宁宫;其次这个模型原先需要采用RBM的方法逐层初始化,以现在训练NN的技术也可以不用了,所以上面的训练过程和一般的神经网络并没有什么区别。
下面是一个使用PCA自编码和使用深度神经网络自编码的实验对比结果
我们可以看到都是编码到30维之后再进行解码,深度自编码器的效果比PCA的效果要好很多。其中有一点需要注意,在使用神经网络的时候,第一个隐层的神经元的个数是多于输入层神经元的个数。
如果用两种方法都将数据降低至2维进行表示,可以看到实验结果如下
可以看到PCA得到的结果将不同种类的数据区分的不是很开,而深度自编码器可以将数据区分的比较开。但是与之前的t-SNE相比还是有一定差距的。
2. 文字检索或者图片检索
将图片或者文字进行深度自编码之后,将它们编码的结果作为它们的特征,将输入的图像或者文字经过同样的编码,在编码后的空间比较相似性,完成文字搜索或者图片搜索。
3. 预训练DNN
在之前训练DNN的技术没有现在这么先进,所以需要通过预训练的方法帮助网络收敛。具体方法如下
左侧是我们最终希望得到的网络,右边是我进行与训练方法的第一步。我们将数据进行自编码,注意,这里的隐层的神经元的数量远远高于,所以要防止网络根本没有训练,直接将数据传到隐层再传到输出层的情况,所以在训练这一层的时候可以加入一项较大的