changeset 1320:881bce55a203

pca bugfix when both max energy and max components are specified
author James Bergstra <bergstrj@iro.umontreal.ca>
date Sun, 10 Oct 2010 13:39:28 -0400
parents 7185d194bb7e
children ebcb76b38817
files pylearn/preprocessing/pca.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/preprocessing/pca.py	Fri Oct 08 12:07:56 2010 -0400
+++ b/pylearn/preprocessing/pca.py	Sun Oct 10 13:39:28 2010 -0400
@@ -62,7 +62,7 @@
         if max_energy_fraction < 1.0:
             energy = 0
             i = 0
-            while energy < max_energy_fraction * vartot:
+            while (energy < max_energy_fraction * vartot) and (i < len(w)):
                 energy += w[i]
                 i += 1
             if i < len(w):