diff --git a/examples/notebooks/EfficientNet_Cifar100_finetuning.ipynb b/examples/notebooks/EfficientNet_Cifar100_finetuning.ipynb index ae59e7712cc..b275f0e3538 100644 --- a/examples/notebooks/EfficientNet_Cifar100_finetuning.ipynb +++ b/examples/notebooks/EfficientNet_Cifar100_finetuning.ipynb @@ -1429,10 +1429,7 @@ "metadata": {}, "outputs": [], "source": [ - "from ignite.contrib.handlers import CustomPeriodicEvent\n", - "\n", - "cpe = CustomPeriodicEvent(n_epochs=3)\n", - "cpe.attach(trainer)\n", + "from ignite.handlers import global_step_from_engine\n", "\n", "\n", "def run_evaluation(engine):\n", @@ -1440,23 +1437,27 @@ " evaluator.run(test_loader)\n", "\n", "\n", - "trainer.add_event_handler(cpe.Events.EPOCHS_3_STARTED, run_evaluation)\n", + "trainer.add_event_handler(Events.EPOCH_STARTED(every=3), run_evaluation)\n", "trainer.add_event_handler(Events.COMPLETED, run_evaluation)\n", "\n", "\n", "# Log train eval metrics:\n", - "tb_logger.attach(train_evaluator,\n", - " log_handler=OutputHandler(tag=\"training\",\n", - " metric_names=list(metrics.keys()),\n", - " another_engine=trainer),\n", - " event_name=Events.EPOCH_COMPLETED)\n", + "tb_logger.attach_output_handler(\n", + " train_evaluator,\n", + " event_name=Events.EPOCH_COMPLETED\n", + " tag=\"training\",\n", + " metric_names=list(metrics.keys()),\n", + " global_step_transform=global_step_from_engine(trainer)\n", + ")\n", "\n", "# Log val metrics:\n", - "tb_logger.attach(evaluator,\n", - " log_handler=OutputHandler(tag=\"test\",\n", - " metric_names=list(metrics.keys()),\n", - " another_engine=trainer),\n", - " event_name=Events.EPOCH_COMPLETED)" + "tb_logger.attach_output_handler(\n", + " evaluator,\n", + " event_name=Events.EPOCH_COMPLETED,\n", + " tag=\"test\",\n", + " metric_names=list(metrics.keys()),\n", + " global_step_transform=global_step_from_engine(trainer)\n", + ")" ] }, { @@ -1513,7 +1514,7 @@ "es_patience = 10\n", "es_handler = EarlyStopping(patience=es_patience, score_function=default_score_fn, trainer=trainer)\n", "evaluator.add_event_handler(Events.COMPLETED, es_handler)\n", - "setup_logger(es_handler._logger)\n", + "setup_logger(es_handler.logger)\n", "\n", "\n", "# Clear cuda cache between training/testing\n", @@ -1840,4 +1841,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +}