Skip to content
Snippets Groups Projects
Commit cbf1f1c5 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[algorithm] fixed criteria for stopping the training loop

parent 0d6da9b9
Branches
Tags
1 merge request!50Add new classification algorithms
Pipeline #
...@@ -98,12 +98,12 @@ class MLP(Algorithm): ...@@ -98,12 +98,12 @@ class MLP(Algorithm):
n_iter = 0 n_iter = 0
previous_cost = 0 previous_cost = 0
current_cost = 1 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 previous_cost = current_cost
trainer.train(self.mlp, X, Y) trainer.train(self.mlp, X, Y)
current_cost = trainer.cost(self.mlp, X, Y) current_cost = trainer.cost(self.mlp, X, Y)
n_iter += 1 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') f = bob.io.base.HDF5File(projector_file, 'w')
self.mlp.save(f) self.mlp.save(f)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment