Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelCheckpoint instance to JSON #3047

Closed
mpariente opened this issue Aug 19, 2020 · 2 comments · Fixed by #3048
Closed

ModelCheckpoint instance to JSON #3047

mpariente opened this issue Aug 19, 2020 · 2 comments · Fixed by #3048
Labels
feature Is an improvement or enhancement help wanted Open to be worked on

Comments

@mpariente
Copy link
Contributor

🚀 Feature

Have a to_json(path) function that writes the best_k_models to a json file in path.

Motivation

Why having a JSON is good?
Then you don't need to load the checkpoints to know the metrics and things like a posteriori stochastic weight averaging gets easier.

It used to be easier in 0.6, but loss values are now tensors, so it's not directly serializable.
This is currently needed:

best_k = {k: v.item() for k, v in checkpoint.best_k_models.items()}
with open(json_path, "w") as f:
    json.dump(best_k, f, indent=0)

Instead, we could have

checkpoint.to_json(json_path)

I'm ready to make a PR for it. Just tell me if this would be useful for you.

@mpariente mpariente added feature Is an improvement or enhancement help wanted Open to be worked on labels Aug 19, 2020
@awaelchli
Copy link
Contributor

should this file be saved with every checkpoint, or one file that gets updated/overwritten?

@mpariente
Copy link
Contributor Author

I just thought about a single function that can be called by the user at the end of training.
But actually, updating/overwritting at every checkpoint also would be cool, at least the user never has to call it.
Link to the PR #3048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement help wanted Open to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants