Provide a scope for the whole training process.
(self, model, callbacks=None, use_samples=False, verbose=0,
mode=ModeKeys.TRAIN)
| 663 | |
| 664 | @tf_contextlib.contextmanager |
| 665 | def on_start(self, model, callbacks=None, use_samples=False, verbose=0, |
| 666 | mode=ModeKeys.TRAIN): |
| 667 | """Provide a scope for the whole training process.""" |
| 668 | # TODO(omalleyt): Handle ProgBar as part of Callbacks once hooks are ready. |
| 669 | progbar = training_utils.get_progbar( |
| 670 | model, 'samples' if use_samples else 'steps') |
| 671 | progbar.params = callbacks.params |
| 672 | progbar.params['verbose'] = verbose |
| 673 | callbacks.model.stop_training = False |
| 674 | callbacks._call_begin_hook(mode) |
| 675 | progbar.on_train_begin() |
| 676 | |
| 677 | # Cache those two instance so that it can be used in other functions. |
| 678 | self.callbacks = callbacks |
| 679 | self.progbar = progbar |
| 680 | |
| 681 | try: |
| 682 | yield |
| 683 | finally: |
| 684 | # End of all epochs |
| 685 | self.callbacks._call_end_hook(mode) |
| 686 | |
| 687 | @tf_contextlib.contextmanager |
| 688 | def on_epoch(self, epoch=0, mode=ModeKeys.TRAIN): |
no test coverage detected