question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inflexible score function of CheckpointSaver

See original GitHub issue

https://github.com/Project-MONAI/MONAI/blob/9f9b63a7dc56d8b31d4fc8d34aae77865ba95947/monai/handlers/checkpoint_saver.py#L148-L160

Currently the CheckpointSaver saves the check point that has the largest score value. However, this is not desirable when a lower score indicates better performance, e.g. validation loss. We can either allow the user to pass a custom score function (as in the ignite.handlers), or add a flag to control returning round(engine.state.metrics[metric_name], 4) or - round(engine.state.metrics[metric_name], 4)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
vfdev-5commented, Jun 28, 2021

Hi @Nic-Ma , in ignite we provide (since v0.4.3) a default score function from metric : https://pytorch.org/ignite/generated/ignite.handlers.checkpoint.Checkpoint.html#ignite.handlers.checkpoint.Checkpoint.get_default_score_fn in addition to score_function argument such that both cases: larger-better or lower-better are covered:

from ignite.handlers import Checkpoint

best_acc_score = Checkpoint.get_default_score_fn("accuracy")
best_model_handler = Checkpoint(
    to_save, save_handler, score_name="val_accuracy", score_function=best_acc_score
)
evaluator.add_event_handler(Events.COMPLETED, best_model_handler)

and

from ignite.handlers import Checkpoint

neg_loss_score = Checkpoint.get_default_score_fn("loss", -1.0)
best_model_handler = Checkpoint(
    to_save, save_handler, score_name="val_neg_loss", score_function=neg_loss_score
)
evaluator.add_event_handler(Events.COMPLETED, best_model_handler)

Maybe, something similar could be done from MONAI’s side ?

1reaction
vfdev-5commented, Jun 30, 2021

@Nic-Ma thanks ! Yes, I agree that it is better to show actual value instead of negative one. We had previously abs(score) such that negative values become positive but we removed that. Now, the main pain point is that score function return negative value as well…

Read more comments on GitHub >

github_iconTop Results From Across the Web

OPTIMISTIC SEMANTIC SYNCHRONIZATION - SMARTech
The main purpose of using open nesting is to separate physical conflicts from semantic conflicts since the programmer usually only cares about the...
Read more >
Active and Passive Control in High-Throughput Microfluidic ...
1.1 functional components and unit operations. 3 large numbers of user-defined droplets (11). Put simply, passive strategies.
Read more >
Untitled
Beardmore inflexible aircraft, Viscous definition science, Povanocni, Kingdom of gwynedd flag, ... Aparthotel altamar puerto rico, Bruins score horn?
Read more >
restoring from checkpoint failed. t - OSCHINA
Caused by op 'save/RestoreV2', defined at: File "D:/tensorflow_learning/neural_network_based_slim/structure_of_the_model.py", line 59, ...
Read more >
Abrahams 2016 - TensorFlow for Machine Intelligence.pdf ...
Instead, TensorFlow provides an extensive suite of functions and classes that ... With some libraries, you are given rigid, pre-built models that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found