Whitening
From Ufldl
for
Whitening
Jump to:
navigation
,
search
== Introduction == We have used PCA to reduce the dimension of the data. There is a closely related preprocessing step called '''whitening''' (or, in some other literatures, '''sphering''') which is needed for some algorithms. If we are training on images, the raw input is redundant, since adjacent pixel values are highly correlated. 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. == 2D example == We will first describe whitening using our previous 2D example. We will then describe how this can be combined with smoothing, and finally how to combine this with PCA. How can we make our input features uncorrelated with each other? We had already done this when computing <math>\textstyle x_{\rm rot}^{(i)} = U^Tx^{(i)}</math>. Repeating our previous figure, our plot for <math>\textstyle x_{\rm rot}</math> was: [[File:PCA-rotated.png | 600px]] The covariance matrix of this data is given by: <math>\begin{align} \begin{bmatrix} 7.29 & 0 \\ 0 & 0.69 \end{bmatrix}. \end{align}</math> (Note: Technically, many of the statements in this section about the "covariance" will be true only if the data has zero mean. In the rest of this section, we will take this assumption as implicit in our statements. However, even if the data's mean isn't exactly zero, the intuitions we're presenting here still hold true, and so this isn't something that you should worry about.) It is no accident that the diagonal values are <math>\textstyle \lambda_1</math> and <math>\textstyle \lambda_2</math>. Further, the off-diagonal entries are zero; thus, <math>\textstyle x_{{\rm rot},1}</math> and <math>\textstyle x_{{\rm rot},2}</math> are uncorrelated, satisfying one of our desiderata for whitened data. To make each of our input features have unit variance, we can simply rescale each feature <math>\textstyle x_{{\rm rot},i}</math> by <math>\textstyle 1/\sqrt{\lambda_i}</math>. Concretely, we define our whitened data <math>\textstyle x_{{\rm PCAwhite}} \in \Re^n</math> as follows: :<math>\begin{align} x_{{\rm PCAwhite},i} = \frac{x_{{\rm rot},i} }{\sqrt{\lambda_i}}. \end{align}</math> Plotting <math>\textstyle x_{{\rm PCAwhite}}</math>, we get: [[File:PCA-whitened.png | 600px]] This data now has covariance equal to the identity matrix <math>\textstyle I</math>. We say that <math>\textstyle x_{{\rm PCAwhite}}</math> is our '''PCA whitened''' version of the data: The different components of <math>\textstyle x_{{\rm PCAwhite}}</math> are uncorrelated and have unit variance. '''Whitening combined with dimensionality reduction.''' If you want to have data that is whitened and which is lower dimensional than the original input, you can also optionally keep only the top <math>\textstyle k</math> components of <math>\textstyle x_{{\rm PCAwhite}}</math>. When we combine PCA whitening with regularization (described later), the last few components of <math>\textstyle x_{{\rm PCAwhite}}</math> will be nearly zero anyway, and thus can safely be dropped. == ZCA Whitening == Finally, it turns out that this way of getting the data to have covariance identity <math>\textstyle I</math> isn't unique. Concretely, if <math>\textstyle R</math> is any orthogonal matrix, so that it satisfies <math>\textstyle RR^T = R^TR = I</math> (less formally, if <math>\textstyle R</math> is a rotation/reflection matrix), then <math>\textstyle R \,x_{\rm PCAwhite}</math> will also have identity covariance. In '''ZCA whitening''', we choose <math>\textstyle R = U</math>. We define :<math>\begin{align} x_{\rm ZCAwhite} = U x_{\rm PCAwhite} \end{align}</math> Plotting <math>\textstyle x_{\rm ZCAwhite}</math>, we get: [[File:ZCA-whitened.png | 600px]] It can be shown that out of all possible choices for <math>\textstyle R</math>, this choice of rotation causes <math>\textstyle x_{\rm ZCAwhite}</math> to be as close as possible to the original input data <math>\textstyle x</math>. When using ZCA whitening (unlike PCA whitening), we usually keep all <math>\textstyle n</math> 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 <math>\textstyle \lambda_i</math> will be numerically close to 0, and thus the scaling step in the scaling equation from the 2D example above would involve dividing by a value close to zero, and may cause the data to blow up (take on large values) or otherwise be numerically unstable. In practice, we implement the scaling step using a small amount of regularization, and add a small constant <math>\textstyle \epsilon</math> to the eigenvalues before taking their square root and inverse: :<math>\begin{align} x_{{\rm PCAwhite},i} = \frac{x_{{\rm rot},i} }{\sqrt{\lambda_i + \epsilon}}. \end{align}</math> When <math>\textstyle x</math> takes values around <math>\textstyle [-1,1]</math>, a value of <math>\textstyle \epsilon \approx 10^{-5}</math> might be typical. <!-- With this form of regularization, the features won't all --> For the case of images, adding <math>\textstyle \epsilon</math> 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 <math>\textstyle x</math> to <math>\textstyle x_{\rm ZCAwhite}</math>. 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.
Template:Languages
(
view source
)
Template:PCA
(
view source
)
Return to
Whitening
.
Views
Page
Discussion
View source
History
Personal tools
Log in
ufldl resources
UFLDL Tutorial
Recommended Readings
wiki
Main page
Recent changes
Random page
Help
Search
Toolbox
What links here
Related changes
Special pages