Whitening

The goal of whitening is to make the input less redundant; more formally, our desiderata are that our learning algorithms sees a training input where (i) the features are less correlated with each other, and (ii) the features all have the same variance.

example

How can we make our input features uncorrelated with each other? We had already done this when computing . Repeating our previous figure, our plot for was:

The covariance matrix of this data is given by:

It is no accident that the diagonal values are and . Further, the off-diagonal entries are zero; thus, and are uncorrelated, satisfying one of our desiderata for whitened data (that the features be less correlated).

To make each of our input features have unit variance, we can simply rescale each feature by . Concretely, we define our whitened data as follows:

Plotting , we get:

This data now has covariance equal to the identity matrix . We say that is our PCA whitened version of the data: The different components of are uncorrelated and have unit variance.

ZCA Whitening

Finally, it turns out that this way of getting the data to have covariance identity isn‘t unique. Concretely, if is any orthogonal matrix, so that it satisfies (less formally, if is a rotation/reflection matrix), then will also have identity covariance. In ZCA whitening, we choose . We define

Plotting , we get:

It can be shown that out of all possible choices for , this choice of rotation causes to be as close as possible to the original input data .

When using ZCA whitening (unlike PCA whitening), we usually keep all dimensions of the data, and do not try to reduce its dimension.

Regularizaton

When implementing PCA whitening or ZCA whitening in practice, sometimes some of the eigenvalues will be numerically close to 0, and thus the scaling step where we divide by would involve dividing by a value close to zero; this may cause the data to blow up (take on large values) or otherwise be numerically unstable. In practice, we therefore implement this scaling step using a small amount of regularization, and add a small constant to the eigenvalues before taking their square root and inverse:

When takes values around , a value of might be typical.

For the case of images, adding here also has the effect of slightly smoothing (or low-pass filtering) the input image. This also has a desirable effect of removing aliasing artifacts caused by the way pixels are laid out in an image, and can improve the features learned (details are beyond the scope of these notes).

ZCA whitening is a form of pre-processing of the data that maps it from to . It turns out that this is also a rough model of how the biological eye (the retina) processes images. Specifically, as your eye perceives images, most adjacent "pixels" in your eye will perceive very similar values, since adjacent parts of an image tend to be highly correlated in intensity. It is thus wasteful for your eye to have to transmit every pixel separately (via your optic nerve) to your brain. Instead, your retina performs a decorrelation operation (this is done via retinal neurons that compute a function called "on center, off surround/off center, on surround") which is similar to that performed by ZCA. This results in a less redundant representation of the input image, which is then transmitted to your brain.

时间: 2024-10-13 15:32:46

Whitening的相关文章

PCA和Whitening

PCA: PCA的具有2个功能,一是维数约简(可以加快算法的训练速度,减小内存消耗等),一是数据的可视化. PCA并不是线性回归,因为线性回归是保证得到的函数是y值方面误差最小,而PCA是保证得到的函数到所降的维度上的误差最小.另外线性回归是通过x值来预测y值,而PCA中是将所有的x样本都同等对待. 在使用PCA前需要对数据进行预处理,首先是均值化,即对每个特征维,都减掉该维的平均值,然后就是将不同维的数据范围归一化到同一范围,方法一般都是除以最大值.但是比较奇怪的是,在对自然图像进行均值处理时

【DeepLearning】Exercise:PCA and Whitening

Exercise:PCA and Whitening 习题链接:Exercise:PCA and Whitening pca_gen.m %%================================================================ %% Step 0a: Load data % Here we provide the code to load natural image data into x. % x will be a 144 * 10000 matr

PCA and Whitening on natural images

Step 0: Prepare data Step 0a: Load data The starter code contains code to load a set of natural images and sample 12x12 patches from them. The raw patches will look something like this: These patches are stored as column vectors in the matrix x. Step

Deep Learning by Andrew Ng --- PCA and whitening

这是UFLDL的编程练习.具体教程参照官网. PCA PCA will find the priciple direction and the secodary direction in 2-dimention examples. then x~(i)=x(i)rot,1=uT1x(i)∈R. is big when x(i)rot,2=uT2x(i) was small. so PCA drop x(i)rot,2=uT2x(i) approximate them with 0's. Whit

UFLDL教程之(三)PCA and Whitening exercise

Exercise:PCA and Whitening 第0步:数据准备 UFLDL下载的文件中,包含数据集IMAGES_RAW,它是一个512*512*10的矩阵,也就是10幅512*512的图像 (a)载入数据 利用sampleIMAGESRAW函数,从IMAGES_RAW中提取numPatches个图像块儿,每个图像块儿大小为patchSize,并将提取到的图像块儿按列存放,分别存放在在矩阵patches的每一列中,即patches(:,i)存放的是第i个图像块儿的所有像素值 (b)数据去均

OpenCV 图像处理:白化(whitening)

原理 图像白化(whitening)可用于对过度曝光或低曝光的图片进行处理,处理的方式就是改变图像的平均像素值为 0 ,改变图像的方差为单位方差 1.我们需要先计算原图像的均值和方差,然后对原图像的每个像素值做变换.假设图像 P 有 I 行 J 列,每个像素的值为 pij, 均值和方差的计算公式如下. 变换后新图像的每个像素值 xij 为 OpenCV 实现 用 OpenCV 的内置函数计算均值和方差,然后对遍历每个像素值并对每个像素做变换.这里需要注意的是变换后的像素值肯定是有一部分会是负值(

Modeling Filters and Whitening Filters

Colored and White Process White Process White Process,又称为White Noise(白噪声),其中white来源于白光,寓意着PSD的平坦分布,white noise指的就是在PSD上具有平坦分布(常数)的随机过程.PSD是auto-correlation的傅里叶变换,PSD上为常数意味着auto-correlation是一个位于零点上的脉冲函数. 回顾auto-correlation的定义: $R_{xx}(\tau) = E\Big\{x

PCA whitening

对输入数据,维度为2时,想要把数据降维1维: 数据的主方向就是旋转数据的第一维.因此,若想把这数据降到一维,可令: 数据已经进行预处理(零均值),使得每个特征和具有相同的均值和方差. PCA算法将寻找一个低维空间来投影我们的数据.从下图中可以看出,是数据变化的主方向,而 是次方向. 为更形式化地找出方向和,我们首先计算出协方差矩阵,如下所示: 就是协方差矩阵的主特征向量,而是次特征向量.(按照特征值得大小选取) 向量和构成了一个新基,可以用来表示数据.那么就是样本点在维度上的投影的长度(幅值).

深度学习入门教程UFLDL学习实验笔记三:主成分分析PCA与白化whitening

主成分分析与白化是在做深度学习训练时最常见的两种预处理的方法,主成分分析是一种我们用的很多的降维的一种手段,通过PCA降维,我们能够有效的降低数据的维度,加快运算速度.而白化就是为了使得每个特征能有同样的方差,降低相邻像素的相关性. 主成分分析PCA PCA算法可以将输入向量转换为一个维数低很多的近似向量.我们在这里首先用2D的数据进行试验,其数据集可以在UFLDL网站的相应页面http://ufldl.stanford.edu/wiki/index.php/Exercise:PCA_in_2D