Last active
October 4, 2017 16:34
-
-
Save lilacs2039/7e831eab0a410be4f352a05a52e9b40a to your computer and use it in GitHub Desktop.
パラメータ記述用オブジェクト デフォルトパラメータ付き (あるいはDTO : Data Transfer Object)
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
""" | |
↓を参考に、デフォルトパラメータ機能もつけた | |
参考:http://python-3-patterns-idioms-test.readthedocs.io/en/latest/Messenger.html | |
""" | |
class EncDecParam: | |
def __init__(self,**kwargs): | |
default_param= {"block":0,"each_block_shortcut":True,"global_ShortCut":False,"en_batch_norm":True,"downScale_conv_kernel":3} | |
for k,v in default_param.items(): | |
self.__dict__[k] =kwargs.get(k,v) | |
""" | |
Usage | |
""" | |
enc_params = ( | |
EncDecParam(block=0,each_block_shortcut=False,downScale_conv_kernel=4), | |
EncDecParam(block=2, downScale_conv_kernel=4), | |
) | |
for i in range: | |
p = enc_params[i] | |
print(str(p.block)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment