Commit 287abb39 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[algorithm] fixed precision criterion to stop training

parent 2df027e0
......@@ -38,7 +38,6 @@ class MLP(Algorithm):
# The data
batch_size = len(training_features[0]) + len(training_features[1])
print(batch_size)
label_real = numpy.ones((len(training_features[0]), 1), dtype='float64')
label_attack = numpy.zeros((len(training_features[1]), 1), dtype='float64')
......@@ -68,12 +67,12 @@ class MLP(Algorithm):
previous_cost = 0
current_cost = 1
precision = 0.001
while (n_iter < self.max_iter) or (abs(previous_cost - current_cost) < precision):
while (n_iter < self.max_iter) or (abs(previous_cost - current_cost) > precision):
previous_cost = current_cost
trainer.train(self.mlp, X, Y)
current_cost = trainer.cost(self.mlp, X, Y)
n_iter += 1
print("Iteration {} -> cost = {} (previous = {})".format(n_iter, trainer.cost(self.mlp, X, Y), previous_cost))
#print("Iteration {} -> cost = {} (previous = {})".format(n_iter, trainer.cost(self.mlp, X, Y), previous_cost))
f = bob.io.base.HDF5File(projector_file, 'w')
self.mlp.save(f)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment