Skip to content

Commit

Permalink
Simplify check for convergence in backprop.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ranma42 committed Dec 17, 2014
1 parent 91f66f6 commit ccab74b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pybrain/supervised/trainers/backprop.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pybrain.supervised.trainers.trainer import Trainer
from pybrain.utilities import fListToString
from pybrain.auxiliary import GradientDescent
from functools import reduce


class BackpropTrainer(Trainer):
Expand Down Expand Up @@ -249,7 +248,8 @@ def trainUntilConvergence(self, dataset=None, maxEpochs=None, verbose=None,
if min(new) > max(old):
self.module.params[:] = bestweights
break
elif reduce(lambda x, y: x + (y - round(new[-1], convergence_threshold)), [round(y, convergence_threshold) for y in new]) == 0:
lastnew = round(new[-1], convergence_threshold)
if sum(round(y, convergence_threshold) - lastnew for y in new) == 0:
self.module.params[:] = bestweights
break
#self.trainingErrors.append(self.testOnData(trainingData))
Expand Down

0 comments on commit ccab74b

Please sign in to comment.