changeset 715:fb9fb142098f

Bugfix and improvement to NIPS09Stopper
author Pascal Lamblin <lamblinp@iro.umontreal.ca>
date Sun, 24 May 2009 17:16:38 -0400
parents 8d5d42274bd1
children 573e3370d0fa
files pylearn/sandbox/nips09stopper.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/sandbox/nips09stopper.py	Fri May 22 15:14:34 2009 -0400
+++ b/pylearn/sandbox/nips09stopper.py	Sun May 24 17:16:38 2009 -0400
@@ -32,14 +32,17 @@
     def find_min(self, step, check, save):
         best = None
         while not self.stop:
-            self.iter++
+            self.iter += 1
             step()
             if (self.iter % self.set_score_interval == 0):
                 self.train_score, self.valid_score = check()
-                if (self.valid_score < self.best_valid) and save:
-                    self.best_valid = self.valid_score
-                    self.best_valid_iter = self.iter
-                    best = (save(), self.iter, self.valid_score)
+                if save:
+                    if (self.valid_score < self.best_valid):
+                        self.best_valid = self.valid_score
+                        self.best_valid_iter = self.iter
+                        best = [save(), self.iter, self.valid_score, self.iter]
+                    else:
+                        best[3] = self.iter
 
             if self.iter >= self.n_iter_max:
                 self.stop = True