0
0

More than 3 years have passed since last update.

ConfigDict()の基本のき

Last updated at Posted at 2021-02-09

ConfigDict()とは

This is a container for configurations. It behaves similarly to Lua tables.
Specifically:
- it has dot-based access as well as dict-style key access,
- it is type safe (once a value is set one cannot change its type).

Lua tables?
使ったことないからわからない。

簡単に辞書が作れるイメージで返り値はyamlっぽいやつ

from ml_collections import config_dict
dict_name = config_dict.ConfigDict()
dict_name.key = value
dict_name.new_dict = config_dict.ConfigDict()
dict_name.new_dict.new_key = new_value
dict_name.tuple = (0, 1)

print(dict_name)
# key: value
# new_dict: 
#   new_key: new_value
# tuple: !!python/tuple [0, 1]

# Pythonのdictでそれっぽく示すと以下の感じ
# dict_name = {'key': value, 
#              'new_dict': {new_key: new_value}
#              'tuple': (0, 1)}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0