Skip to content

Instantly share code, notes, and snippets.

@jcreinhold
Created May 16, 2021 23:17
Show Gist options
  • Save jcreinhold/c22cd3629d9ce6a918dd3fbed27fc8b0 to your computer and use it in GitHub Desktop.
Save jcreinhold/c22cd3629d9ce6a918dd3fbed27fc8b0 to your computer and use it in GitHub Desktop.
convert a dictionary to an AttributeDict
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