-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support **DictConfig hparam serialization #2519
Conversation
Hello @romesco! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-08-11 10:03:26 UTC |
Let me update this to actual casting, I was using the OmegaConf API, but this is likely creating a new object which is definitely not memory efficient... |
For a bit more clarification, this is fixing the case where the
followed by this constructor call:
where cfg is a I am unpacking the With that in mind, I would prefer to unpack, but that leads me to the issue where |
I don't understand what is an 'unpacked DictConfig'. What are you actually passing in as hparams? Looking at the fix, it does not make much sense to me. |
like this
and what you dont like? |
I see, so you a dict that have some DictConfig objects in it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost good, just some minor changes
Codecov Report
@@ Coverage Diff @@
## master #2519 +/- ##
=======================================
+ Coverage 89% 90% +1%
=======================================
Files 80 80
Lines 7531 7425 -106
=======================================
- Hits 6738 6709 -29
+ Misses 793 716 -77 |
Made all the requested changes. All (non docs) CI tests are passing! |
pytorch_lightning/core/saving.py
Outdated
@@ -17,7 +17,7 @@ | |||
try: | |||
from omegaconf import OmegaConf | |||
except ImportError: | |||
Container = None | |||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want OmegaConf = None
here, otherwise you are accessing an uninitialized variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you're right, forgot after removing Container
to replace this
This pull request is now in conflict... :( |
* change to OmegaConf API Co-authored-by: Omry Yadan <[email protected]> * Swapped Container for OmegaConf sentinel; Limited ds copying * Add Namespace check. * Container removed. Pass local tests. Co-authored-by: Omry Yadan <[email protected]>
What does this PR do?
Context: Passing an unpacked
DictConfig
to__init__()
and then callingsave_hyperparameters()
Bug:
save_hyperparameters()
deals with the unpackedDictConfig
as adict
which might still contain values of typeDictConfig
. Upon serialization during saving, this errors out because it is handled withyaml.dump()
.Fix: Enables OmegaConf to serialize the object as originally intended by casting back to a
DictConfig
.Fixes: #2844
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Always.