Initialize the parameters, then combine the parameters parsed by the parser and the parameters read by config
(self, parser, args=None)
| 143 | self.build_conf(parser, args) |
| 144 | |
| 145 | def build_conf(self, parser, args=None): |
| 146 | """Initialize the parameters, then combine the parameters parsed by the parser and the parameters read by config""" |
| 147 | args = parser.parse_args(args) |
| 148 | self.read(args.config_path) |
| 149 | self.namespace = argparse.Namespace() |
| 150 | self.update( |
| 151 | dict((name, ast.literal_eval(value)) for section in self.sections() for name, value in self.items(section))) |
| 152 | args.nranks = paddle.distributed.get_world_size() |
| 153 | args.local_rank = paddle.distributed.get_rank() |
| 154 | args.fields_path = os.path.join(args.model_files, "fields") |
| 155 | args.model_path = os.path.join(args.model_files, "model") |
| 156 | # update config from args |
| 157 | self.update(vars(args)) |
| 158 | return self |
| 159 | |
| 160 | def __repr__(self): |
| 161 | """repr""" |