Debian Codegraph @

ml_collections/config_flags/examples/define_config_file_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 # pylint: disable=line-too-long
16 r"""Example of basic DEFINE_flag_dict usage.
17
18 To run this example with basic config file:
19 python define_config_dict_basic.py -- \
20 --my_config=ml_collections/config_flags/examples/config.py
21 \
22 --my_config.field1=8 --my_config.nested.field=2.1 \
23 --my_config.tuple='(1, 2, (1, 2))'
24
25 To run this example with parameterised config file:
26 python define_config_dict_basic.py -- \
27 --my_config=ml_collections/config_flags/examples/parameterised_config.py:linear
28 \
29 --my_config.model_config.output_size=256'
30 """
31 # pylint: enable=line-too-long
32
33 from absl import app
34
35 from ml_collections import config_flags
36
37 _CONFIG = config_flags.DEFINE_config_file('my_config')
38
39
40 def main(_):
41 print(_CONFIG.value)
42
43
44 if __name__ == '__main__':
45 app.run(main)