Created
May 16, 2021 23:17
-
-
Save jcreinhold/c22cd3629d9ce6a918dd3fbed27fc8b0 to your computer and use it in GitHub Desktop.
convert a dictionary to an AttributeDict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pytorch_lightning.utilities.parsing import AttributeDict as adict | |
def to_adict(d: dict) -> adict: | |
""" recursively convert a dictionary to an AttributeDict """ | |
for k, v in d.items(): | |
if isinstance(v, dict): | |
d[k] = to_adict(v) | |
return adict(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment