主成分分析

From Ufldl

Jump to: navigation, search
Line 127: Line 127:
== 选择主成分个数 ==
== 选择主成分个数 ==
-
我们该如何选择 ,即保留多少个PCA主成分?在上面这个简单的二维实验中,保留第一个成分看起来是自然的选择。对于高维数据来说,做这个决定就没那么简单:如果 <math>\textstyle k</math> 过大,数据压缩率不高,在极限情况 <math>\textstyle k=n</math> 时,等于是在使用原始数据(只是旋转投射到了不同的基);相反地,如果 <math>\textstyle k</math> 过小,那数据的近似误差太太。
+
我们该如何选择 <math>\textstyle k</math> ,即保留多少个PCA主成分?在上面这个简单的二维实验中,保留第一个成分看起来是自然的选择。对于高维数据来说,做这个决定就没那么简单:如果 <math>\textstyle k</math> 过大,数据压缩率不高,在极限情况 <math>\textstyle k=n</math> 时,等于是在使用原始数据(只是旋转投射到了不同的基);相反地,如果 <math>\textstyle k</math> 过小,那数据的近似误差太太。
 +
决定 <math>\textstyle k</math> 值时,我们通常会考虑不同 <math>\textstyle k</math> 值可保留的方差百分比。具体来说,如果 <math>\textstyle k=n</math> ,那么我们得到的是对数据的完美近似,也就是保留了100%的方差,即原始数据的所有变化都被保留下来;相反,如果 <math>\textstyle k=0</math> ,那等于是使用零向量来逼近输入数据,也就是只有0%的方差被保留下来。
-
 
+
一般而言,设 <math>\textstyle \lambda_1, \lambda_2, \ldots, \lambda_n</math> 表示 <math>\textstyle \Sigma</math> 的特征值(按由大到小顺序排列),使得 <math>\textstyle \lambda_j</math> 为对应于特征向量 <math>\textstyle u_j</math> 的特征值。那么如果我们保留前 <math>\textstyle k</math> 个成分,则保留的方差百分比可计算为:
-
【原文】:To decide how to set <math>\textstyle k</math>, we will usually look at the '''percentage of variance retained'''
+
-
for different values of <math>\textstyle k</math>.  Concretely, if <math>\textstyle k=n</math>, then we have
+
-
an exact approximation to the data, and we say that 100% of the variance is
+
-
retained.  I.e., all of the variation of the original data is retained. 
+
-
Conversely, if <math>\textstyle k=0</math>, then we are approximating all the data with the zero vector,
+
-
and thus 0% of the variance is retained.
+
-
 
+
-
【初译】:在决定<math>\textstyle k</math>的过程中,我们通常会计算不同<math>\textstyle k</math>值可保留的方差百分比,具体来说,如果<math>\textstyle k=n</math>,那么我们得到的是对数据的完美近似,也就是保留了100%的方差,即原始数据的所有变化特性(variation)都被保留下来;如果<math>\textstyle k=0</math>,那么我们是在使用零向量来近似输入数据,因此也就只有0%的方差可以被保留。
+
-
 
+
-
【一审】:为了决定<math>\textstyle k</math>值,我们通常会计算不同<math>\textstyle k</math>值可保留的方差百分比,具体来说,如果<math>\textstyle k=n</math>,那么我们得到的是对数据的完美近似,也就是保留了100%的方差,即原始数据的所有变化特性(variation)都被保留下来;如果<math>\textstyle k=0</math>,那么我们是在使用零向量来近似输入数据,因此也就只有0%的方差可以被保留。
+
-
 
+
-
【二审】:在决定<math>\textstyle k</math>值设置的过程中,我们通常会计算不同<math>\textstyle k</math>值可保留的方差百分比,具体来说,如果<math>\textstyle k=n</math>,那么我们得到的是对数据的完美近似,也就是保留了100%的方差,即原始数据的所有变化都被保留下来;相反,如果<math>\textstyle k=0</math>,那么我们是在使用零向量来近似输入数据,因此也就只有0%的方差可以被保留。
+
-
 
+
-
 
+
-
【原文】:More generally, let <math>\textstyle \lambda_1, \lambda_2, \ldots, \lambda_n</math> be the eigenvalues
+
-
of <math>\textstyle \Sigma</math> (sorted in decreasing order), so that <math>\textstyle \lambda_j</math> is the eigenvalue
+
-
corresponding to the eigenvector <math>\textstyle u_j</math>.  Then if we retain <math>\textstyle k</math> principal components,
+
-
the percentage of variance retained is given by:
+
-
 
+
-
【初译】:更一般的情况,假设<math>\textstyle \lambda_1, \lambda_2, \ldots, \lambda_n</math>表示<math>\textstyle \Sigma</math>的特征值(按由大到小顺序排列),则<math>\textstyle \lambda_j</math>为对应于特征向量<math>\textstyle u_j</math>的特征值,如果我们保留前<math>\textstyle k</math>个成分,则保留的方差百分比可计算为:
+
-
 
+
-
【一审】:更一般的情况,假设<math>\textstyle \lambda_1, \lambda_2, \ldots, \lambda_n</math>表示<math>\textstyle \Sigma</math>的特征值(按由大到小降序排列),则<math>\textstyle \lambda_j</math>为对应于特征向量<math>\textstyle u_j</math>的特征值,如果我们保留前<math>\textstyle k</math>个主成分,则保留的方差百分比可计算为:
+
-
 
+
-
【二审】:更一般的情况,假设<math>\textstyle \lambda_1, \lambda_2, \ldots, \lambda_n</math>表示<math>\textstyle \Sigma</math>的特征值(按由大到小顺序排列),则<math>\textstyle \lambda_j</math>为对应于特征向量<math>\textstyle u_j</math>的特征值,如果我们保留前<math>\textstyle k</math>个成分,则保留的方差百分比可计算为:
+
:<math>\begin{align}
:<math>\begin{align}
Line 160: Line 137:
\end{align}</math>
\end{align}</math>
 +
在上面简单的二维实验中,<math>\textstyle \lambda_1 = 7.29</math> ,<math>\textstyle \lambda_2 = 0.69</math> 。因此,如果保留 <math>\textstyle k=1</math> 个主成分,等于我们保留了 <math>\textstyle 7.29/(7.29+0.69) = 0.913</math> ,即91.3%的方差。
-
【原文】:In our simple 2D example above, <math>\textstyle \lambda_1 = 7.29</math>, and <math>\textstyle \lambda_2 = 0.69</math>.  Thus,
+
对保留方差的百分比进行更正式的定义已超出了本教程的范围,但很容易证明,<math>\textstyle \lambda_j =
-
by keeping only <math>\textstyle k=1</math> principal components, we retained <math>\textstyle 7.29/(7.29+0.69) = 0.913</math>,
+
\sum_{i=1}^m x_{{\rm rot},j}^2</math> 。因此,如果 <math>\textstyle \lambda_j \approx 0</math> ,则说明 <math>\textstyle x_{{\rm rot},j}</math> 也就基本上接近于0,所以用0来近似它并不会产生多大损失。这也解释了为什么要保留前面的主成分(对应的 <math>\textstyle \lambda_j</math> 值较大)而不是末尾的那些。 这些前面的主成分 <math>\textstyle x_{{\rm rot},j}</math> 变化性更大,取值也更大,如果将其设为0势必引入较大的近似误差。
-
or 91.3% of the variance.
+
-
【初译】:在我们的二维实验中,<math>\textstyle \lambda_1 = 7.29</math>,<math>\textstyle \lambda_2 = 0.69</math>,保留前<math>\textstyle k=1</math>个主成分,也等于我们保留了<math>\textstyle 7.29/(7.29+0.69) = 0.913</math>,即91.3%的方差。
+
以处理图像数据为例,一个惯常的经验法则是选择 <math>\textstyle k</math> 以保留99%的方差,换句话说,我们选取满足以下条件的最小 <math>\textstyle k</math> 值:
-
【一审】:上面我们的二维实验中,<math>\textstyle \lambda_1 = 7.29</math>,<math>\textstyle \lambda_2 = 0.69</math>,保留前<math>\textstyle k=1</math>个主成分,也等于我们保留了<math>\textstyle 7.29/(7.29+0.69) = 0.913</math>,即91.3%的方差。
 
-
 
-
【二审】:上面我们简单的二维实验中,<math>\textstyle \lambda_1 = 7.29</math>,<math>\textstyle \lambda_2 = 0.69</math>,因此,仅保留<math>\textstyle k=1</math>个主成分,等于我们保留了<math>\textstyle 7.29/(7.29+0.69) = 0.913</math>,即91.3%的方差。
 
-
 
-
 
-
【原文】:A more formal definition of percentage of variance retained is beyond the scope
 
-
of these notes.  However, it is possible to show that <math>\textstyle \lambda_j =
 
-
\sum_{i=1}^m x_{{\rm rot},j}^2</math>.  Thus, if <math>\textstyle \lambda_j \approx 0</math>, that shows that
 
-
<math>\textstyle x_{{\rm rot},j}</math> is usually near 0 anyway, and we lose relatively little by
 
-
approximating it with a constant 0.  This also explains why we retain the top principal
 
-
components (corresponding to the larger values of <math>\textstyle \lambda_j</math>) instead of the bottom
 
-
ones.  The top principal components
 
-
<math>\textstyle x_{{\rm rot},j}</math> are the ones that're more variable and that take on larger values,
 
-
and for which we would incur a greater approximation error if we were to set them to zero.
 
-
 
-
【初译】:虽然对保留方差的百分比进行更规范的定义已超出了本教程的范围,但退一步说,因可以证明<math>\textstyle \lambda_j =
 
-
\sum_{i=1}^m x_{{\rm rot},j}^2</math>,如果<math>\textstyle \lambda_j \approx 0</math>,则说明<math>\textstyle x_{{\rm rot},j}</math>基本接近于0,将其赋值为常数0因而并不会产生较大损失,这也解释了为什么要保留排名靠前的主成分(对应值较大的<math>\textstyle \lambda_j</math>)而不是末尾的那些, 这些排名靠前的主成分<math>\textstyle x_{{\rm rot},j}</math>方差更大,值也较大,如果设为0将引入较大的近似误差。
 
-
 
-
【一审】:虽然对保留方差的百分比进行更规范的定义已超出了本笔记的范围,但很容易判断,<math>\textstyle \lambda_j =
 
-
\sum_{i=1}^m x_{{\rm rot},j}^2</math>,如果<math>\textstyle \lambda_j \approx 0</math>,则说明<math>\textstyle x_{{\rm rot},j}</math>基本接近于0,将其赋值为常数0因而并不会产生较大损失,这也解释了为什么要保留排名靠前的主成分(对应值较大的<math>\textstyle \lambda_j</math>)而不是末尾的那些, 这些排名靠前的主成分<math>\textstyle x_{{\rm rot},j}</math>方差更大,值也较大,如果设为0将引入较大的近似误差。
 
-
 
-
【二审】:虽然对保留方差的百分比进行更规范的定义已超出了本教程的范围,但很容易判断<math>\textstyle \lambda_j =
 
-
\sum_{i=1}^m x_{{\rm rot},j}^2</math>,,因可以证明,如果<math>\textstyle \lambda_j \approx 0</math>,则说明<math>\textstyle x_{{\rm rot},j}</math>基本接近于0,将其赋值为常数0因而并不会产生较大损失,这也解释了为什么要保留排名靠前的主成分(对应<math>\textstyle \lambda_j</math>值较大的)而不是末尾的那些,这些排名靠前的主成分<math>\textstyle x_{{\rm rot},j}</math>变动更大,因此值也更大,如果设为0将引入较大的近似误差。
 
-
 
-
 
-
【原文】:In the case of images, one common heuristic is to choose <math>\textstyle k</math> so as to retain 99% of
 
-
the variance.  In other words, we pick the smallest value of <math>\textstyle k</math> that satisfies
 
:<math>\begin{align}
:<math>\begin{align}
\frac{\sum_{j=1}^k \lambda_j}{\sum_{j=1}^n \lambda_j} \geq 0.99.  
\frac{\sum_{j=1}^k \lambda_j}{\sum_{j=1}^n \lambda_j} \geq 0.99.  
\end{align}</math>
\end{align}</math>
-
Depending on the application, if you are willing to incur some
 
-
additional error, values in the 90-98% range are also sometimes used.  When you
 
-
describe to others how you applied PCA, saying that you chose <math>\textstyle k</math> to retain 95% of
 
-
the variance will also be a much more easily interpretable description than saying
 
-
that you retained 120 (or whatever other number of) components.
 
-
【初译】:处理图像数据时,一个惯常的经验法则是选择<math>\textstyle k</math>以保留99%的方差,换一句话说,我们选择所有满足以下条件的<math>\textstyle k</math>中的最小值:
+
对其它应用,如不介意引入稍大的误差,有时也保留90-98%的方差范围。若向他人介绍PCA算法详情,告诉他们你选择的 <math>\textstyle k</math> 保留了95%的方差,比告诉他们你保留了前120个(或任意某个数字)主成分更好理解。
-
:<math>\begin{align}
+
-
\frac{\sum_{j=1}^k \lambda_j}{\sum_{j=1}^n \lambda_j} \geq 0.99.
+
-
\end{align}</math>
+
-
对于其它的应用,如果不介意引入的误差稍大,那保留方差百分比在90-98%范围内可能都合理。若向他人介绍PCA算法,告诉他们你选择的<math>\textstyle k</math>是为了保留95%的方差相较于直接告诉他们你保留了前120个(或任意某个数字)主成分也更便于他人理解。
+
-
【一审】:处理图像数据时,一个惯常的经验法则是选择<math>\textstyle k</math>以保留99%的方差,换一句话说,我们选择所有满足以下条件的<math>\textstyle k</math>中的最小值:
+
== 对图像数据应用PCA算法 ==
-
:<math>\begin{align}
+
-
\frac{\sum_{j=1}^k \lambda_j}{\sum_{j=1}^n \lambda_j} \geq 0.99.
+
-
\end{align}</math>
+
-
对于其它的应用,如果不介意引入的误差稍大,那保留方差百分比在90-98%范围内可能都合理。若向他人介绍PCA算法,告诉他们你选择的<math>\textstyle k</math>是为了保留95%的方差相较于直接告诉他们你保留了前120个(或任意某个数字)主成分也更便于他人理解。
+
-
【二审】:以处理图像数据为例,一个惯常的经验法则是选择<math>\textstyle k</math>以保留99%的方差,换句话说,我们选取满足以下条件的最小<math>\textstyle k</math>值:
+
为使PCA算法能有效工作,通常我们希望所有的特征 <math>\textstyle x_1, x_2, \ldots, x_n</math> 都有相似的取值范围(并且均值接近于0)。如果你曾在其它应用中使用过PCA算法,你可能知道有必要单独对每个特征做预处理,即通过估算每个特征 <math>\textstyle x_j</math> 的均值和方差,而后将其取值范围规整化为零均值和单位方差。但是,对于大部分图像类型,我们却不需要进行这样的预处理。假定我们将在自然图像上训练算法,此时特征 <math>\textstyle x_j</math> 代表的是像素 <math>\textstyle j</math> 的值。所谓“自然图像”,不严格的说,是指人或动物在他们一生中所见的那种图像。
-
:<math>\begin{align}
+
-
\frac{\sum_{j=1}^k \lambda_j}{\sum_{j=1}^n \lambda_j} \geq 0.99.
+
-
\end{align}</math>
+
-
对其它应用,如不介意引入稍大的误差,有时也仅保留90-98%的方差范围。若向他人介绍PCA算法,告诉他们你选择的<math>\textstyle k</math>是为保留95%的方差,比告诉他们你保留了前120个(或任意某个数字)主成分更便于他人理解。
+
 +
注:通常我们选取含草木等内容的户外场景图片,然后从中随机截取小图像块(如16x16像素)来训练算法。在实践中我们发现,大多数特征学习算法对训练图片的确切类型并不敏感,所以大多数用普通照相机拍摄的图片,只要不是特别的模糊或带有非常奇怪的人工痕迹,都可以使用。
 +
在自然图像上进行训练时,对每一个像素单独估计均值和方差意义不大,因为(理论上)图像任一部分的统计性质都应该和其它部分相同,图像的这种特性被称作平稳性(stationarity)。
-
== PCA on Images 对图像数据应用PCA算法 ==
+
具体而言,为使PCA算法正常工作,我们通常需要满足以下要求:(1)特征的均值大致为0;(2)不同特征的方差值彼此相似。对于自然图片,即使不进行方差归一化操作,条件(2)也自然满足,故而我们不再进行任何方差归一化操作(对音频数据,如声谱,或文本数据,如词袋向量,我们通常也不进行方差归一化)。实际上,PCA算法对输入数据具有缩放不变性,无论输入数据的值被如何放大(或缩小),返回的特征向量都不改变。更正式的说:如果将每个特征向量 <math>\textstyle x</math> 都乘以某个正数(即所有特征量被放大或缩小相同的倍数),PCA的输出特征向量都将不会发生变化。
 +
既然我们不做方差归一化,唯一还需进行的规整化操作就是均值规整化,其目的是保证所有特征的均值都在0附近。根据应用,在大多数情况下,我们并不关注所输入图像的整体明亮程度。比如在对象识别任务中,图像的整体明亮程度并不会影响图像中存在的是什么物体。更为正式地说,我们对图像块的平均亮度值不感兴趣,所以可以减去这个值来进行均值规整化。
-
【原文】:For PCA to work, usually we want each of the features <math>\textstyle x_1, x_2, \ldots, x_n</math>
+
具体的步骤是,如果 <math>\textstyle x^{(i)} \in \Re^{n}</math> 代表16x16的图像块的亮度(灰度)值( <math>\textstyle n=256</math> ),可用如下算法来对每幅图像进行零均值化操作:
-
to have a similar range of values to the others (and to have a mean close to
+
-
zero).  If you've used PCA on other applications before, you may therefore have
+
-
separately pre-processed each feature to have zero mean and unit variance, by
+
-
separately estimating the mean and variance of each feature <math>\textstyle x_j</math>.  However,
+
-
this isn't the pre-processing that we will apply to most types of images.  Specifically,
+
-
suppose we are training our algorithm on '''natural images''', so that <math>\textstyle x_j</math> is
+
-
the value of pixel <math>\textstyle j</math>.  By "natural images," we informally mean the type of image that
+
-
a typical animal or person might see over their lifetime.
+
-
 
+
-
【初译】:为使PCA算法能正常工作,通常我们希望所有的特征<math>\textstyle x_1, x_2, \ldots, x_n</math>都有相似的取值范围(并且均值接近于0)。如果你曾对其它数据应用过PCA算法,你可能知道有必要单独对每个特征<math>\textstyle x_j</math>做预处理,估算其均值和方差以将其规范为零均值和单位方差。对于大部分的图像文件,我们却不进行这样的预处理,尤其是在我们使用“自然图像”(natural images)来训练算法时——“自然图像”可不正规的定义为通常动物或者人类可肉眼看到的图像类型——此时特征<math>\textstyle x_j</math>代表的是像素<math>\textstyle j</math>的值。
+
-
 
+
-
【一审】:为使PCA算法能有效,通常我们希望所有的特征<math>\textstyle x_1, x_2, \ldots, x_n</math>都有相似的取值范围(并且均值接近于0)。如果你曾在其它应用使用过PCA算法,你可能知道有必要单独对每个特征<math>\textstyle x_j</math>做预处理,估算其均值和方差以将其规范为零均值和单位方差。对于大部分的图像文件,我们却不进行这样的预处理,尤其是在我们使用“自然图像”(natural images)来训练算法时,此时特征<math>\textstyle x_j</math>代表的是像素<math>\textstyle j</math>的值。“自然图像”含义是典型的动物或人,在平常生活中所看到的那样。
+
-
 
+
-
【二审】:为使PCA算法能有效,通常我们希望所有的特征<math>\textstyle x_1, x_2, \ldots, x_n</math>都有相似的取值范围(并且均值接近于0)。如果你曾在其它应用中使用过PCA算法,你可能知道有必要单独对每个特征做预处理,估算每个特征<math>\textstyle x_j</math>,将其规范为零均值和单位方差。但是,对于大部分图像文件,我们却不进行这样的预处理,尤其是当我们使用“自然图像”来训练算法时,此时特征<math>\textstyle x_j</math>代表的是像素<math>\textstyle j</math>的值,“自然图像”的含义是典型的动物或人的图像,如日常生活中所看到的那些。
+
-
 
+
-
 
+
-
【原文】:Note: Usually we use images of outdoor scenes with grass, trees, etc., and cut out small (say 16x16) image patches randomly from these to train the algorithm.  But in practice most feature learning algorithms are extremely robust to the exact type of image  it is trained on, so most images taken with a normal camera, so long as they aren't excessively blurry or have strange artifacts, should work. 
+
-
 
+
-
【初译】:注:通常我们使用户外拍摄草木等场景的照片,并从中随机截取小图像块(大小为16乘16像素)来训练算法,实际应用中我们发现,大多数特征学习算法对于训练的图片类型都具有极大的鲁棒性(robust),普通照相机拍摄的图片,只要不是特别的模糊或者有非常奇怪的人工痕迹,都应可以使用。
+
-
 
+
-
【一审】:注:通常我们使用户外拍摄草木等场景的照片,并从中随机截取小图像块(大小为16乘16像素)来训练算法,实际应用中我们发现,大多数特征学习算法对于训练的图片类型都具有极大的鲁棒性(robust),普通照相机拍摄的图片,只要不是特别的模糊或者有非常奇怪的人工痕迹,都应可以使用。
+
-
 
+
-
【二审】:注:通常我们使用户外拍摄草木等场景的照片,并从中随机截取小图像块(如16x16像素)来训练算法。但实际应用中我们发现,大多数特征学习算法对于训练的图片类型都具有极大的鲁棒性,普通照相机拍摄的图片,只要不是特别的模糊或者有非常奇怪的人工痕迹,都应可以使用。
+
-
 
+
-
 
+
-
【原文】:When training on natural images, it makes little sense to estimate a separate mean and
+
-
variance for each pixel, because the statistics in one part
+
-
of the image should (theoretically) be the same as any other. 
+
-
This property of images is called '''stationarity.'''
+
-
 
+
-
【初译】:在自然图片上训练时,对每一个像素估计一个单独的均值和方差意义不大,因为理论上,图像任一部分的统计数据都应该和任意其它部分相同,图像的这种特性被称作平稳性(stationarity)。
+
-
 
+
-
【一审】:在自然图片上训练时,对每一个像素估计一个单独的均值和方差意义不大,因为理论上,图像任一部分的统计数据都应该和任意其它部分相同,图像的这种特性被称作平稳性(stationarity)。
+
-
 
+
-
【二审】:在自然图片上训练时,对每一个像素估计一个单独的均值和方差意义不大,因为(理论上)图像某一部分的统计数据都应该和任意其它部分相同,图像的这种特性被称作平稳性。
+
-
 
+
-
 
+
-
【原文】:In detail, in order for PCA to work well, informally we require that (i) The
+
-
features have approximately zero mean, and (ii) The different features have
+
-
similar variances to each other.  With natural images, (ii) is already
+
-
satisfied even without variance normalization, and so we won't perform any
+
-
variance normalization. 
+
-
(If you are training on audio data---say, on
+
-
spectrograms---or on text data---say, bag-of-word vectors---we will usually not perform
+
-
variance normalization either.) 
+
-
In fact, PCA is invariant to the scaling of
+
-
the data, and will return the same eigenvectors regardless of the scaling of
+
-
the input.  More formally, if you multiply each feature vector <math>\textstyle x</math> by some
+
-
positive number (thus scaling every feature in every training example by the
+
-
same number), PCA's output eigenvectors will not change. 
+
-
 
+
-
【初译】:具体操作中,为使PCA算法正常工作,我们通常需要满足以下要求:(1) 特征的均值大致为0; (2) 不同的特征的方差相似。对于自然图片,即使不进行方差归一化操作,条件(2)也永远满足,故而我们不进行任何方差归一化操作 (当处理音频文件时,比如声谱,或者文本文件,比如bag-of-word向量,我们通常也不做方差归一化处理)。实际上,PCA算法对于输入数据具有放大(scaling)不变性,无论输入数据的值被如何放大(或缩小),返回的特征值都不改变。下面给出这一说法更规范的描述:如果将每个特征量<math>\textstyle x</math>都乘以同一个正数(即所有特征量被放大或缩小了相同的倍数),PCA的输出特征向量将不会发生变化。
+
-
 
+
-
【一审】:具体操作中,为使PCA算法正常工作,我们通常需要满足以下要求:(1) 特征的均值大致为0; (2) 不同的特征的方差相似。对于自然图片,即使不进行方差归一化操作,条件(2)也永远满足,故而我们不进行任何方差归一化操作 (当处理音频数据时,比如声谱,或者文本数据,比如词袋向量,我们通常也不做方差归一化处理)。实际上,PCA算法对于输入数据具有放大(scaling)不变性,无论输入数据的值被如何放大(或缩小),返回的特征值都不改变。下面给出这一说法更规范的描述:如果将每个特征量<math>\textstyle x</math>都乘以同一个正数(即所有特征量被放大或缩小了相同的倍数),PCA的输出特征向量将不会发生变化。
+
-
 
+
-
【二审】:具体操作中,为使PCA算法正常工作,我们通常需要满足以下要求:(1) 特征的均值大致为0; (2) 不同特征具备相似的方差。对于自然图片,即使不进行方差归一化操作,条件(2)也永远满足,故而我们不进行任何方差归一化操作 (当处理如声谱等音频数据,或如词袋向量等文本数据时,我们通常也不做方差归一化处理)。实际上,PCA算法对输入数据具有缩放不变性,无论输入数据的值被如何放大(或缩小),返回的特征向量都不改变。更规范的说:如果将每个特征向量<math>\textstyle x</math>都乘以同一个正数(即所有特征量被放大或缩小相同的倍数),PCA的输出特征向量将不会发生变化。
+
-
 
+
-
 
+
-
【原文】:So, we won't use variance normalization.  The only normalization we need to
+
-
perform then is mean normalization, to ensure that the features have a mean
+
-
around zero.  Depending on the application, very often we are not interested
+
-
in how bright the overall input image is.  For example, in object recognition
+
-
tasks, the overall brightness of the image doesn't affect what objects
+
-
there are in the image.  More formally, we are not interested in the
+
-
mean intensity value of an image patch; thus, we can subtract out this value,
+
-
as a form of mean normalization. 
+
-
 
+
-
【初译】:既然我们不做方差归一化,唯一还需进行的规范化操作就是均值规范化,其目的是保证所有特征的均值都在0附近。根据不同的应用,很多情况下我们并不关注所输入的图像文件的明亮程度,比如对于物体识别,图像的整体明亮程度并不影响图像中存在的是什么物体。更为规范地说,我们对某一个图像的平均强度值不感兴趣,因此我们可以减去这个值来进行均值规范化(即零均值化)。
+
-
 
+
-
【一审】:既然我们不做方差归一化,唯一还需进行的规范化操作就是均值规范化,其目的是保证所有特征的均值都在0附近。根据不同的应用,很多情况下我们并不关注所输入的图像文件的明亮程度,比如对于物体识别,图像的整体明亮程度并不影响图像中存在的是什么物体。更为规范地说,我们对某一个图像的平均强度值不感兴趣,因此我们可以减去这个值来进行均值规范化(即零均值化)。
+
-
 
+
-
【二审】:既然我们不做方差归一化,唯一还需进行的规范化操作就是均值规范化,其目的是保证所有特征均值都在0附近。根据不同的应用,很多情况下我们并不关注所输入的图像文件的明亮程度,比如对于物体识别,图像的整体明亮程度并不影响图像中存在的是什么物体。更为规范地说,我们对某一块图像的平均亮度值不感兴趣,因此我们可以减去这个值来进行均值规范化。
+
-
 
+
-
 
+
-
【原文】:Concretely, if <math>\textstyle x^{(i)} \in \Re^{n}</math> are the (grayscale) intensity values of
+
-
a 16x16 image patch (<math>\textstyle n=256</math>), we might normalize the intensity of each image
+
-
<math>\textstyle x^{(i)}</math> as follows:
+
<math>\mu^{(i)} := \frac{1}{n} \sum_{j=1}^n x^{(i)}_j</math>
<math>\mu^{(i)} := \frac{1}{n} \sum_{j=1}^n x^{(i)}_j</math>
Line 309: Line 168:
<math>x^{(i)}_j := x^{(i)}_j - \mu^{(i)}</math>, for all <math>\textstyle j</math>
<math>x^{(i)}_j := x^{(i)}_j - \mu^{(i)}</math>, for all <math>\textstyle j</math>
-
【初译】:具体的步骤是,如果<math>\textstyle x^{(i)} \in \Re^{n}</math>代表16乘16的图像块的灰度值(<math>\textstyle n=256</math>),我们可以应用如下算法来对每一个图像块<math>\textstyle x^{(i)}</math>的(灰度)强度值进行零均值化操作:
+
请注意:1)对每个输入图像块 <math>\textstyle x^{(i)}</math> 都要单独执行上面两个步骤,2)这里的  <math>\textstyle \mu^{(i)}</math> 是指图像块 <math>\textstyle x^{(i)}</math> 的平均亮度值。尤其需要注意的是,这和为每个像素 <math>\textstyle x_j</math> 单独估算均值是两个完全不同的概念。
-
<math>\mu^{(i)} := \frac{1}{n} \sum_{j=1}^n x^{(i)}_j</math>
+
如果你处理的图像并非自然图像(比如,手写文字,或者白背景正中摆放单独物体),其他规整化操作就值得考虑了,而哪种做法最合适也取决于具体应用场合。但对自然图像而言,对每幅图像进行上述的零均值规整化,是默认而合理的处理。
-
<math>x^{(i)}_j := x^{(i)}_j - \mu^{(i)}</math> (对所有的<math>\textstyle j</math>)
+
== 参考文献 ==
 +
http://cs229.stanford.edu
-
【一审】:具体的步骤是,如果<math>\textstyle x^{(i)} \in \Re^{n}</math>代表16乘16的图像块的灰度值(<math>\textstyle n=256</math>),我们可以应用如下算法来对每一个图像块<math>\textstyle x^{(i)}</math>的(灰度)强度值进行零均值化操作:
 
-
<math>\mu^{(i)} := \frac{1}{n} \sum_{j=1}^n x^{(i)}_j</math>
+
专有名词对应表
-
 
+
Principal Components Analysis 主成份分析
-
<math>x^{(i)}_j := x^{(i)}_j - \mu^{(i)}</math> (对所有的<math>\textstyle j</math>)
+
whitening 白化
-
 
+
intensity 亮度
-
【二审】:具体的步骤是,如果<math>\textstyle x^{(i)} \in \Re^{n}</math>代表16x16的图像块的亮度(灰度)值(<math>\textstyle n=256</math>),我们可以应用如下算法来对每一个图像块的亮度值进行零均值化操作:
+
mean 平均值
-
 
+
variance 方差
-
<math>\mu^{(i)} := \frac{1}{n} \sum_{j=1}^n x^{(i)}_j</math>
+
covariance matrix 协方差矩阵
-
 
+
basis 基
-
<math>x^{(i)}_j := x^{(i)}_j - \mu^{(i)}</math> (对所有的<math>\textstyle j</math>)
+
magnitude  幅值
-
 
+
stationarity  平稳性
-
 
+
normalization 归一化
-
【原文】:Note that the two steps above are done separately for each image <math>\textstyle x^{(i)}</math>,
+
eigenvector  特征向量
-
and that <math>\textstyle \mu^{(i)}</math> here is the mean intensity of the image <math>\textstyle x^{(i)}</math>.  In particular,
+
eigenvalue  特征值
-
this is not the same thing as estimating a mean value separately for each pixel <math>\textstyle x_j</math>.
+
-
 
+
-
【初译】:请注意上面两个步骤需要单独对每个输入图像块<math>\textstyle x^{(i)}</math>应用,且<math>\textstyle \mu^{(i)}</math>计算的是每个图像块<math>\textstyle x^{(i)}</math>的平均强度值,尤其需要注意的是,这和试图为每一个像素<math>\textstyle x_j</math>单独估算均值是完全不同的概念。
+
-
 
+
-
【一审】:请注意上面两个步骤需要单独对每个输入图像块<math>\textstyle x^{(i)}</math>应用,且<math>\textstyle \mu^{(i)}</math>计算的是每个图像块<math>\textstyle x^{(i)}</math>的平均强度值,尤其需要注意的是,这和试图为每一个像素<math>\textstyle x_j</math>单独估算均值是完全不同的概念。
+
-
 
+
-
【二审】:请注意上面两个步骤需要单独对每个输入图像块<math>\textstyle x^{(i)}</math>应用,且计算的是每个图像块<math>\textstyle x^{(i)}</math>的平均亮度值<math>\textstyle \mu^{(i)}</math>,尤其需要注意的是,这和试图为每一个像素<math>\textstyle x_j</math>单独估算均值是完全不同的概念。
+
-
 
+
-
 
+
-
【原文】:If you are training your algorithm on images other than natural images (for example, images of handwritten characters, or images of single isolated objects centered against a white background), other types of normalization might be worth considering, and the best choice may be application dependent. But when training on natural images, using the per-image mean normalization method as given in the equations above would be a reasonable default.
+
-
 
+
-
【初译】:如果你处理的图像并非自然图像(比如,手写文字,或者白背景正中摆放单独物体),其他规范化操作可能就值得引入,哪种做法最合适也将依赖于具体应用场合,但是对自然图像进行训练时,使用如上所述的整个图像块范围内的均值规范化操作可以放心假定为合理的办法。
+
-
 
+
-
【一审】:如果你处理的图像并非自然图像(比如,手写文字,或者白背景正中摆放单独物体),其他规范化操作可能就值得考虑了,哪种做法最合适也将依赖于具体应用场合,但是对自然图像进行训练时,使用如上所述的整个图像块范围内的均值规范化操作可以放心假定为合理的办法。
+
-
 
+
-
【二审】:如果你处理的图像并非自然图像(比如,手写文字,或者白背景正中摆放单独物体),其他规范化操作可能就值得考虑了,哪种做法最合适也将依赖于具体应用场合,但是对自然图像进行训练时,使用如上所述的整个图像块范围内的均值规范化操作可以放心假定为合理的办法。
+
-
 
+
-
== References 参考文献 ==
+
-
http://cs229.stanford.edu
+

Revision as of 15:09, 20 March 2013

Personal tools