def on_start(func): """ The :func:`on_start` decorator is used to initialise a :class:`.Callback` with :meth:`~.Callback.on_start` calling the decorated function :param func: The function(state) to *decorate* :type func: function :return: Initialised callback with :meth:`~.Callback.on_start` calling func :rtype: :class:`.Callback` """ callback = Callback() callback.on_start = func return callback
def test_empty_methods(self): callback = Callback() self.assertIsNone(callback.on_start({})) self.assertIsNone(callback.on_start_epoch({})) self.assertIsNone(callback.on_start_training({})) self.assertIsNone(callback.on_sample({})) self.assertIsNone(callback.on_forward({})) self.assertIsNone(callback.on_criterion({})) self.assertIsNone(callback.on_backward({})) self.assertIsNone(callback.on_step_training({})) self.assertIsNone(callback.on_end_training({})) self.assertIsNone(callback.on_end_epoch({})) self.assertIsNone(callback.on_end({})) self.assertIsNone(callback.on_start_validation({})) self.assertIsNone(callback.on_sample_validation({})) self.assertIsNone(callback.on_forward_validation({})) self.assertIsNone(callback.on_end_validation({})) self.assertIsNone(callback.on_step_validation({})) self.assertIsNone(callback.on_criterion_validation({}))