[DLMED] add event-handler to save checkpoint
"import nibabel as nib\n",
"\n",
"from ignite.engine import Events, create_supervised_trainer\n",
+ "from ignite.handlers import ModelCheckpoint\n",
"\n",
"# assumes the framework is found here, change as necessary\n",
"sys.path.append(\"..\")\n",
"\n",
"trainer = create_supervised_trainer(net, opt, loss_fn, device, False)\n",
"\n",
+ "checkpoint_handler = ModelCheckpoint('./', 'net', n_saved=10, require_empty=False)\n",
+ "trainer.add_event_handler(\n",
+ " event_name=Events.EPOCH_COMPLETED,\n",
+ " handler=checkpoint_handler,\n",
+ " to_save={'net': net}\n",
+ ")\n",
"\n",
"@trainer.on(Events.EPOCH_COMPLETED)\n",
"def log_training_loss(engine):\n",
