白化
From Ufldl
Line 1: | Line 1: | ||
- | + | == 介绍 == | |
- | + | ||
- | + | ||
- | + | ||
- | + | 我们已经了解了如何使用PCA降低数据维度。在一些算法中还需要一个与之相关的预处理步骤,这个预处理过程称为'''白化'''(一些文献中也叫'''sphering''')。举例来说,假设训练数据是图像,由于图像中相邻像素之间具有很强的相关性,所以用于训练时输入是冗余的。白化的目的就是降低输入的冗余性;更正式的说,我们希望通过白化过程使得学习算法的输入具有如下性质:(i)特征之间相关性较低;(ii)所有特征具有相同的方差。 | |
- | + | ||
- | |||
- | + | == 2D 的例子 == | |
- | + | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
下面我们先用前文的2D例子描述白化的主要思想,然后分别介绍如何将白化与平滑和PCA相结合。 | 下面我们先用前文的2D例子描述白化的主要思想,然后分别介绍如何将白化与平滑和PCA相结合。 | ||
- | 在前文计算<math>x_{rot}^{(i)}=U^Tx^{(i)}</math> | + | |
+ | 如何消除输入特征之间的相关性? 在前文计算 <math>\textstyle x_{\rm rot}^{(i)} = U^Tx^{(i)}</math> 时实际上已经消除了输入特征<math>\textstyle x^{(i)}</math>之间的相关性。得到的新特征 <math>\textstyle x_{\rm rot}</math> 的分布如下图所示: | ||
[[File:PCA-rotated.png | 600px]] | [[File:PCA-rotated.png | 600px]] | ||
- | + | 这个数据的协方差矩阵如下: | |
- | + | ||
- | <math>\begin{align} | + | :<math>\begin{align} |
\begin{bmatrix} | \begin{bmatrix} | ||
7.29 & 0 \\ | 7.29 & 0 \\ | ||
Line 41: | Line 21: | ||
\end{align}</math> | \end{align}</math> | ||
- | ( | + | (注: 严格地讲, 这部分许多关于“协方差”的陈述仅当数据均值为0时成立。下文的论述都隐式地假定这一条件成立。不过即使数据均值不为0,下文的说法仍然成立,所以你无需担心这个。) |
- | + | ||
- | + | ||
- | + | <math>\textstyle x_{\rm rot}</math> 协方差矩阵对角元素的值为 <math>\textstyle \lambda_1</math> 和 <math>\textstyle \lambda_2</math> 绝非偶然。并且非对角元素值为0; 因此, <math>\textstyle x_{{\rm rot},1}</math> 和 <math>\textstyle x_{{\rm rot},2}</math> 是不相关的, 满足我们对白化结果的第一个要求 (特征间相关性降低)。 | |
- | + | ||
- | + | 为了使每个输入特征具有单位方差,我们可以直接使用 <math>\textstyle 1/\sqrt{\lambda_i}</math> 作为缩放因子来缩放每个特征 <math>\textstyle x_{{\rm rot},i}</math> 。具体地,我们定义白化后的数据 <math>\textstyle x_{{\rm PCAwhite}} \in \Re^n</math> 如下: | |
+ | |||
+ | :<math>\begin{align} | ||
+ | x_{{\rm PCAwhite},i} = \frac{x_{{\rm rot},i} }{\sqrt{\lambda_i}}. | ||
+ | \end{align}</math> | ||
+ | |||
+ | |||
+ | 绘制出 <math>\textstyle x_{{\rm PCAwhite}}</math> ,我们得到: | ||
+ | |||
+ | [[File:PCA-whitened.png | 600px]] | ||
+ | |||
+ | |||
+ | 这些数据现在的协方差矩阵为单位矩阵 <math>\textstyle I</math> 。我们说,<math>\textstyle x_{{\rm PCAwhite}}</math> 是数据经过'''PCA白化后'''的版本: <math>\textstyle x_{{\rm PCAwhite}}</math> 中不同的特征之间不相关并且具有单位方差。 | ||
+ | |||
+ | '''白化与降维相结合'''。 如果你想要得到经过白化后的数据,并且比初始输入维数更低,可以仅保留 <math>\textstyle x_{{\rm PCAwhite}}</math> 中前 <math>\textstyle k</math> 个成分。当我们把PCA白化和正则化结合起来时(在稍后讨论),<math>\textstyle x_{{\rm PCAwhite}}</math> 中最后的少量成分将总是接近于0,因而舍弃这些成分不会带来很大的问题。 | ||
+ | |||
+ | |||
+ | == ZCA白化 == | ||
+ | |||
+ | 最后要说明的是,使数据的协方差矩阵变为单位矩阵 <math>\textstyle I</math> 的方式并不唯一。具体地,如果 <math>\textstyle R</math> 是任意正交矩阵,即满足 <math>\textstyle RR^T = R^TR = I</math> (说它正交不太严格,<math>\textstyle R</math> 可以是旋转或反射矩阵), 那么 <math>\textstyle R \,x_{\rm PCAwhite}</math> 仍然具有单位协方差。在'''ZCA白化'''中,令 <math>\textstyle R = U</math> 。我们定义ZCA白化的结果为: | ||
+ | |||
+ | :<math>\begin{align} | ||
+ | x_{\rm ZCAwhite} = U x_{\rm PCAwhite} | ||
+ | \end{align}</math> | ||
+ | |||
+ | 绘制 <math>\textstyle x_{\rm ZCAwhite}</math>,得到: | ||
+ | |||
+ | [[File:ZCA-whitened.png | 600px]] | ||
+ | |||
+ | |||
+ | 可以证明,对所有可能的 <math>\textstyle R</math>,这种旋转使得 <math>\textstyle x_{\rm ZCAwhite}</math> 尽可能地接近原始输入数据 <math>\textstyle x</math> 。 | ||
+ | |||
+ | 当使用 ZCA白化时(不同于 PCA白化),我们通常保留数据的全部 <math>\textstyle n</math> 个维度,不尝试去降低它的维数。 | ||
+ | |||
+ | |||
+ | == 正则化 == | ||
+ | |||
+ | 实践中需要实现PCA白化或ZCA白化时,有时一些特征值 <math>\textstyle \lambda_i</math> 在数值上接近于0,这样在缩放步骤时我们除以 <math>\sqrt{\lambda_i}</math> 将导致除以一个接近0的值;这可能使数据上溢 (赋为大数值)或造成数值不稳定。因而在实践中,我们使用少量的正则化实现这个缩放过程,即在取平方根和倒数之前给特征值加上一个很小的常数 <math>\textstyle \epsilon</math>: | ||
+ | |||
+ | :<math>\begin{align} | ||
+ | x_{{\rm PCAwhite},i} = \frac{x_{{\rm rot},i} }{\sqrt{\lambda_i + \epsilon}}. | ||
+ | \end{align}</math> | ||
+ | |||
+ | 当 <math>\textstyle x</math> 在区间 <math>\textstyle [-1,1]</math> 上时, 一般取值为 <math>\textstyle \epsilon \approx 10^{-5}</math>。 | ||
+ | |||
+ | 对图像来说, 这里加上 <math>\textstyle \epsilon</math> ,对输入图像也有一些平滑(或低通滤波)的作用。这样处理还能消除在图像的像素信息获取过程中产生的噪声,改善学习到的特征(细节超出了本文的范围)。 | ||
+ | |||
+ | |||
+ | ZCA 白化是一种数据预处理方法,它将数据从 <math>\textstyle x</math> 映射到 <math>\textstyle x_{\rm ZCAwhite}</math> 。 事实证明这也是一种生物眼睛(视网膜)处理图像的粗糙模型。具体而言,当你的眼睛感知图像时,由于一幅图像中相邻的部分在亮度上十分相关,大多数临近的“像素”在眼中被感知为相近的值。因此,如果人眼需要分别传输每个像素值(通过视觉神经)到大脑中,会非常不划算。取而代之的是,视网膜进行一个与ZCA中相似的去相关操作 (这是由视网膜上的ON-型和OFF-型光感受器细胞将光信号转变为神经信号完成的)。由此得到对输入图像的更低冗余的表示,并将它传输到大脑。 | ||
+ | |||
+ | |||
+ | |||
+ | ==中英文对照== | ||
+ | |||
+ | 白化 whitening | ||
+ | |||
+ | 冗余 redundant | ||
+ | |||
+ | 方差 variance | ||
+ | |||
+ | 平滑 smoothing | ||
+ | |||
+ | 降维 dimensionality reduction | ||
+ | |||
+ | 正则化 regularization | ||
+ | |||
+ | 反射矩阵 reflection matrix | ||
+ | |||
+ | 去相关 decorrelation | ||
+ | |||
+ | |||
+ | |||
+ | ==中文译者== | ||
+ | |||
+ | 杨海川(yanghaichuan@outlook.com), 王文中(wangwenzhong@ymail.com), 谭晓阳(x.tan@nuaa.edu.cn) | ||
- | |||
- | |||
- | + | {{预处理:主成分分析与白化}} | |
- | |||
- | |||
- | + | {{Languages|Whitening|English}} |