diff options
-rw-r--r-- | Wrappers/Python/ccpi/optimisation/Algorithms.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/Algorithms.py b/Wrappers/Python/ccpi/optimisation/Algorithms.py index 9115e6e..0a5cac6 100644 --- a/Wrappers/Python/ccpi/optimisation/Algorithms.py +++ b/Wrappers/Python/ccpi/optimisation/Algorithms.py @@ -84,6 +84,12 @@ class Algorithm(object): def max_iteration(self, value): assert isinstance(value, int) self.__max_iteration = value + def run(self, iterations, callback=None): + '''run n iterations and update the user with the callback if specified''' + self.max_iteration += iterations + for _ in self: + if callback is not None: + callback(self.iteration, self.get_current_loss()) class GradientDescent(Algorithm): '''Implementation of a simple Gradient Descent algorithm |