def on_start_training(func): """ The :func:`on_start_training` decorator is used to initialise a :class:`.Callback` with :meth:`~.Callback.on_start_training` calling the decorated function :param func: The function(state) to *decorate* :type func: function :return: Initialised callback with :meth:`.Callback.on_start_training` calling func :rtype: :class:`.Callback` """ new_callback = Callback() new_callback.on_start_training = func return new_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({}))
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({}))