Debian Codegraph @

ml_collections/config_flags/examples/define_config_dict_basic.py

raw symbols SCIP
1 # Copyright 2024 The ML Collections Authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 r"""Example of basic DEFINE_config_dict usage.
16
17 To run this example:
18 python define_config_dict_basic.py -- --my_config_dict.field1=8 \
19 --my_config_dict.nested.field=2.1 --my_config_dict.tuple='(1, 2, (1, 2))'
20 """
21
22 from absl import app
23
24 from ml_collections import config_dict
25 from ml_collections import config_flags
26
27 config = config_dict.ConfigDict()
28 config.field1 = 1
29 config.field2 = 'tom'
30 config.nested = config_dict.ConfigDict()
31 config.nested.field = 2.23
32 config.tuple = (1, 2, 3)
33
34 _CONFIG = config_flags.DEFINE_config_dict('my_config_dict', config)
35
36
37 def main(_):
38 print(_CONFIG.value)
39
40
41 if __name__ == '__main__':
42 app.run(main)