Skip to content

Instantly share code, notes, and snippets.

@shubhamagarwal92
Created March 25, 2019 14:52
Show Gist options
  • Save shubhamagarwal92/ff07ae107ac4da545adc458b113cdd4b to your computer and use it in GitHub Desktop.
Save shubhamagarwal92/ff07ae107ac4da545adc458b113cdd4b to your computer and use it in GitHub Desktop.
Create dot notation access to dictionary attributes
# Shamelessly taken from https://github.com/huggingface/pytorch-openai-transformer-lm/blob/master/model_pytorch.py
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
config = dotdict({
'n_embd': 768,
'n_head': 12,
'n_layer': 12,
'embd_pdrop': 0.1,
'attn_pdrop': 0.1,
'resid_pdrop': 0.1,
'afn': 'gelu',
'clf_pdrop': 0.1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment