Skip to content

Improve usage of contrib common methods with other save handlers #1123

@vfdev-5

Description

@vfdev-5

🚀 Feature

Currently, methods like common.save_best_model_by_val_score and common.setup_common_training_handlers work with local storage setup by output_path.

If we would like to use other save handlers than DiskSaver, it is almost impossible to use those helpers.

Idea is to be able user's setup of save handler for internal Checkpoint class.
There can be several ways, I see, how to accomplish that:

  • make output_path accept instances of BaseSaveHandler
from ignite.contrib.engines import common

save_handler = TrainsSaver(dirname=output_path)

common.save_best_model_by_val_score(
        save_handler, evaluator, model=model, metric_name="accuracy", n_saved=3, trainer=trainer, tag="test"
)
  • set module-wise default save handler as DiskSaver and allow user to replace it by another save hander:
from ignite.contrib.engines import common

common.default_save_handler = TrainsSaver(dirname=output_path)

common.save_best_model_by_val_score(
        None, evaluator, model=model, metric_name="accuracy", n_saved=3, trainer=trainer, tag="test"
)
  • add another argument save_handler=None
save_handler = TrainsSaver(dirname=output_path)

common.save_best_model_by_val_score(
        None, evaluator, model=model, metric_name="accuracy", n_saved=3, trainer=trainer, tag="test", save_handler=save_handler
)

Any other ideas @sdesrozis @erip ?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions