Skip to content

Commit

Permalink
Remove deprecated CustomPeriodicEvent from nb example, fix tb OutputH…
Browse files Browse the repository at this point in the history
…adler
  • Loading branch information
trsvchn committed Oct 18, 2020
1 parent 5dacbdf commit 822701e
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions examples/notebooks/EfficientNet_Cifar100_finetuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1429,34 +1429,35 @@
"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",
" train_evaluator.run(eval_train_loader)\n",
" 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",
")"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1840,4 +1841,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}

0 comments on commit 822701e

Please sign in to comment.