未验证 提交 9894c06a 编写于 作者: D Dom 提交者: GitHub

Code Refactoring (#4262)

* use dict update

* use dictionary update

---------
Co-authored-by: NLogan Adams <114770087+loadams@users.noreply.github.com>
上级 c93e89a3
......@@ -299,8 +299,7 @@ class BertConfig(object):
if isinstance(vocab_size_or_config_json_file, str):
with open(vocab_size_or_config_json_file, "r", encoding='utf-8') as reader:
json_config = json.loads(reader.read())
for key, value in json_config.items():
self.__dict__[key] = value
self.__dict__.update(json_config)
elif isinstance(vocab_size_or_config_json_file, int):
self.vocab_size = vocab_size_or_config_json_file
self.hidden_size = hidden_size
......@@ -323,8 +322,7 @@ class BertConfig(object):
def from_dict(cls, json_object):
"""Constructs a `BertConfig` from a Python dictionary of parameters."""
config = BertConfig(vocab_size_or_config_json_file=-1)
for key, value in json_object.items():
config.__dict__[key] = value
config.__dict__.update(json_object)
return config
@classmethod
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册