From cbf1f1c56a021542434089fcc5655b2e740442b7 Mon Sep 17 00:00:00 2001 From: Guillaume HEUSCH <guillaume.heusch@idiap.ch> Date: Tue, 10 Jul 2018 10:53:43 +0200 Subject: [PATCH] [algorithm] fixed criteria for stopping the training loop --- bob/pad/base/algorithm/MLP.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bob/pad/base/algorithm/MLP.py b/bob/pad/base/algorithm/MLP.py index 2ea45d8..2f29470 100644 --- a/bob/pad/base/algorithm/MLP.py +++ b/bob/pad/base/algorithm/MLP.py @@ -98,12 +98,12 @@ class MLP(Algorithm): n_iter = 0 previous_cost = 0 current_cost = 1 - while (n_iter < self.max_iter) or (abs(previous_cost - current_cost) > self.precision): + while (n_iter < self.max_iter) and (abs(previous_cost - current_cost) > self.precision): previous_cost = current_cost trainer.train(self.mlp, X, Y) current_cost = trainer.cost(self.mlp, X, Y) n_iter += 1 - logger.debug("Iteration {} -> cost = {} (previous = {})".format(n_iter, trainer.cost(self.mlp, X, Y), previous_cost)) + logger.debug("Iteration {} -> cost = {} (previous = {}, max_iter = {})".format(n_iter, trainer.cost(self.mlp, X, Y), previous_cost, self.max_iter)) f = bob.io.base.HDF5File(projector_file, 'w') self.mlp.save(f) -- GitLab