def add_args(cls, group, params=None, sub_cls=None): for net_name in cls.net_names: add_argument(group, f'{cls.prefix_name()}_{net_name}_cls', type=str) net_cls = Net.load_cls(try_get_attr(params, f'{cls.prefix_name()}_{net_name}_cls', check=False)) if net_cls is not None: net_cls.add_args(group, params) return group
def add_parser(self, root_parser: argparse.ArgumentParser = None): if root_parser is None: root_parser = argparse.ArgumentParser( description=f'{self.module_type} root parser') group_parser = root_parser else: group_parser = root_parser.add_argument_group( f'{self.module_type} group parser') module_cls = self.init_params.get(f'{self.module_type}_cls', self.module_type) add_argument(group_parser, f'{self.module_type}_cls', type=str, help=f'{self.module_type} class name', default=module_cls) return root_parser, group_parser
def add_args(cls, group, params=None, sub_cls=None): add_argument(group, f'{cls.prefix_name()}_layer_names', type=str, nargs='*') group = cls.default_add_args(group, params) layer_cls_names = try_get_attr(params, f'{cls.prefix_name()}_layer_names', check=False) if layer_cls_names is not None: params = cls.collect_layer_params(layer_cls_names) for name, param in params.items(): arg_type = param.annotation arg_type = str_bool if arg_type is bool else arg_type add_argument(group, f'{cls.prefix_name()}_layer_{name}s', type=arg_type, nargs='*') return group
def add_args(cls, group, params=None): super().add_args(group, params) add_argument(group, f'{cls.prefix_name()}_splits', type=str, nargs='*') add_argument(group, f'{cls.prefix_name()}_shuffles', type=str_bool, nargs='*') add_argument(group, f'{cls.prefix_name()}_belongs', type=str, nargs='*') add_argument(group, f'{cls.prefix_name()}_is_lazy', type=str_bool) add_func_args(group, py_data.DataLoader.__init__, cls.prefix_name())
def dynamic_add_args(self): work_dir = self.init_params.get('work_dir', None) or './work_dir' proj_name = self.init_params.get('proj_name', None) or 'project' exp_name = self.init_params.get('exp_name', None) or 'experiment' exp_version = self.init_params.get('exp_version', None) or -1 auto_load = self.init_params.get('auto_load', None) or False add_argument(self.group_parser, 'work_dir', type=str, default=work_dir, help='where to work') add_argument(self.group_parser, 'proj_name', type=str, default=proj_name, help=' name of project') add_argument(self.group_parser, 'exp_name', type=str, default=exp_name, help='experiment name') add_argument(self.group_parser, 'exp_version', default=exp_version, help='experiment version') add_argument(self.group_parser, 'config_file', type=str, help='config file path') add_argument(self.group_parser, 'auto_load', type=str_bool, default=auto_load, help='auto load config file')