Adds functionality to save best model in CheckpointingCallback and fixes a typo#3
Adds functionality to save best model in CheckpointingCallback and fixes a typo#3dmsm wants to merge 2 commits intomgharbi:masterfrom dmsm:master
Conversation
| self.best_val_key = best_val_key | ||
|
|
||
| if best_val_value is not None: | ||
| LOG.info("Loaded best model ({}={})".format(best_val_key, best_val_value)) |
There was a problem hiding this comment.
"loaded" be misleading, since the load does not happen at init time
| @@ -184,7 +184,7 @@ class VisdomLoggingCallback(KeyedCallback): | |||
| 0.0 disables smoothing. | |||
| def __init__(self, checkpointer, interval=600, | ||
| max_files=5, max_epochs=10): | ||
| max_files=5, max_epochs=10, | ||
| best_val_key=None, best_val_value=None): |
There was a problem hiding this comment.
do we need to initialize best_val_value externally? could that be handled by the load/save mechanism so we only have one parameter?
| @@ -506,6 +515,22 @@ def batch_end(self, batch_data, train_step_data): | |||
| self.checkpointer.save(filename, extras={"epoch": self.epoch}) | |||
There was a problem hiding this comment.
here and elsewhere were save is called, we might want to always save the best_val_value for easy loading and treat the "None" case. It could be nice, but not required, to add a "load_best" method to the Checkpointer class.
|
|
||
| if self.best_val_key is None: | ||
| return | ||
| if val_data[self.best_val_key] > self.best_val_value: |
There was a problem hiding this comment.
we should probably document that the "best" is implicitly a min value (e.g. if someone uses accuracy instead of loss)
|
Hello everyone. I have been using torch tools and love it for its simplicity and readability. For example, I tried using pytorch-lightning once instead but I just became nervous because it was harder to see what it is doing behind the scenes. So I quickly came back to ttools. Anyway, I needed a solution for the above problem. It is pretty similar to the above proposal. There are a couple of differences:
Current limitation is that if two models have the exact same score, it'll delete one of them. Hope this is useful |
No description provided.