(self)
| 557 | test_controller.train(steps=10) |
| 558 | |
| 559 | def test_summaries_inside_train_fn(self): |
| 560 | test_runner = TestTrainerWithSummaries() |
| 561 | |
| 562 | checkpoint = tf.train.Checkpoint( |
| 563 | model=test_runner.model, optimizer=test_runner.optimizer) |
| 564 | checkpoint_manager = tf.train.CheckpointManager( |
| 565 | checkpoint, |
| 566 | self.model_dir, |
| 567 | max_to_keep=None, |
| 568 | step_counter=test_runner.global_step) |
| 569 | test_controller = controller.Controller( |
| 570 | trainer=test_runner, |
| 571 | global_step=test_runner.global_step, |
| 572 | steps_per_loop=2, |
| 573 | summary_dir=os.path.join(self.model_dir, "summaries/train"), |
| 574 | summary_interval=2, |
| 575 | checkpoint_manager=checkpoint_manager |
| 576 | ) |
| 577 | test_controller.train(steps=10) |
| 578 | |
| 579 | # Checkpoints are saved. |
| 580 | self.assertEmpty(tf.io.gfile.glob(os.path.join(self.model_dir, "ckpt*"))) |
| 581 | |
| 582 | # Only train summaries are written. |
| 583 | self.assertNotEmpty( |
| 584 | tf.io.gfile.listdir(os.path.join(self.model_dir, "summaries/train"))) |
| 585 | self.assertNotEmpty( |
| 586 | summaries_with_matching_keyword( |
| 587 | "loss", os.path.join(self.model_dir, "summaries/train"))) |
| 588 | self.assertFalse( |
| 589 | tf.io.gfile.exists(os.path.join(self.model_dir, "summaries/eval"))) |
| 590 | |
| 591 | def test_train_and_evaluate_with_same_summary_dir(self): |
| 592 | test_runner = TestRunner() |
nothing calls this directly
no test coverage detected