Mercurial > pylearn
changeset 1360:f81b3b6f9698
corrected use of epsilons in pca
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Thu, 11 Nov 2010 18:08:05 -0500 |
parents | 5db730bb0e8e |
children | 7548dc1b163c |
files | pylearn/preprocessing/pca.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/preprocessing/pca.py Thu Nov 11 17:53:13 2010 -0500 +++ b/pylearn/preprocessing/pca.py Thu Nov 11 18:08:05 2010 -0500 @@ -94,7 +94,7 @@ max_energy_fraction=max_energy_fraction), centered_X -def pca_whiten((eigvals, eigvecs), centered_X,eps=1e-8): +def pca_whiten((eigvals, eigvecs), centered_X,eps=1e-14): """ Return the projection of X onto it's principle components. @@ -106,17 +106,17 @@ """ pca_of_X = numpy.dot(centered_X, eigvecs) - pca_of_X /= numpy.sqrt(eigvals)+eps + pca_of_X /= numpy.sqrt(eigvals+eps) return pca_of_X -def pca_whiten_inverse((eigvals, eigvecs), whitened_X, eps=1e-8): +def pca_whiten_inverse((eigvals, eigvecs), whitened_X, eps=1e-14): """ 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) + 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.