Created
March 25, 2019 14:52
-
-
Save shubhamagarwal92/ff07ae107ac4da545adc458b113cdd4b to your computer and use it in GitHub Desktop.
Create dot notation access to dictionary attributes
This file contains hidden or 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
# 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