kbressem / trainlib

MIT License
4 stars 0 forks source link

Feature request: write current epoch into CheckpointSaver #40

Open markus-hinsche opened 2 years ago

kbressem commented 2 years ago

Do you know how this is implemented into the CheckointSaver I could not find it in the docs? However, it would also be a good idea to also save the optimizer state as well.

markus-hinsche commented 2 years ago

After a quick search, I didn't find anything either yet. +1 on saving the optimizer state

markus-hinsche commented 1 year ago

I researched some more:

Maybe we could use https://pytorch.org/ignite/generated/ignite.handlers.checkpoint.ModelCheckpoint.html#ignite.handlers.checkpoint.ModelCheckpoint

e.g. like

        ModelCheckpoint(
            config.model_dir,
            "myprefix",
            n_saved=1,
            create_dir=True,
            require_empty=False,
            filename_pattern="checkpoint_{epoch}.pth",
        ),

but we would have to create a handler that is compatible with monai, otherwise we get: AttributeError: 'ModelCheckpoint' object has no attribute 'attach'