Mercurial > pylearn
changeset 1276:822c7691a759
pca - added pca_whiten_inverse function
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Tue, 14 Sep 2010 22:35:51 -0400 |
parents | f0129e37a8ef |
children | bef6c5f565cd |
files | pylearn/preprocessing/pca.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/preprocessing/pca.py Wed Sep 08 13:18:13 2010 -0400 +++ b/pylearn/preprocessing/pca.py Tue Sep 14 22:35:51 2010 -0400 @@ -109,6 +109,15 @@ pca_of_X /= numpy.sqrt(eigvals)+eps return pca_of_X +def pca_whiten_inverse((eigvals, eigvecs), whitened_X, eps=1e-8): + """ + Return an approximate inverse of the `pca_whiten` transform. + + The inverse is not perfect because pca_whitening discards the least-significant components + of the data. + """ + return numpy.dot(whitened_X * (numpy.sqrt(eigvals)+eps), eigvecs.T) + def zca_whiten((eigvals, eigvecs), centered_X): """Return the PCA of X but rotated back into the original vector space.