def baseline_main(args): config_path = get_config_path() configs = [] for path, dirs, files in os.walk(config_path): for file in files: file = os.path.join(path, file) match = True for keyword in args.keywords: result = re.search(r"[/\\_.]%s[/\\_.]" % keyword, file) if not result: match = False break if match: configs.append(file) if len(configs) == 0: raise ValueError("Can't find a baseline with keywords: %s" % ", ".join(args.keywords)) if len(configs) > 1: configs = sorted(configs) configs = [""] + [ os.path.relpath(config, config_path) for config in configs ] raise ValueError("Ambiguous keywords. Candidates are:%s" % "\n ".join(configs)) config = configs[0] print("running baseline: %s" % os.path.relpath(config, config_path)) cfg = load_config(config) if args.gpu is not None: cfg.resource.gpus = range(args.gpu) if args.cpu is not None: cfg.resource.cpu_per_gpu = args.cpu if args.epoch is not None: cfg.train.num_epoch = args.epoch app = gap.Application(cfg.application, **cfg.resource) app.load(**cfg.graph) app.build(**cfg.build) if "load" in cfg: app.load_model(**cfg.load) app.train(**cfg.train) if args.eval and "evaluate" in cfg: if isinstance(cfg.evaluate, dict): cfg.evaluate = [cfg.evaluate] for evaluation in cfg.evaluate: app.evaluate(**evaluation) if "save" in cfg: app.save_model(**cfg.save)
def run_main(args): cfg = load_config(args.config) if args.gpu: cfg.resource.gpus = range(args.gpu) if args.cpu: cfg.resource.cpu_per_gpu = args.cpu app = gap.Application(cfg.application, **cfg.resource) app.load(**cfg.graph) app.build(**cfg.build) app.train(**cfg.train) if args.eval and "evaluate" in cfg: app.evaluate(**cfg.evaluate) if "save" in cfg: app.save(**cfg.save)
def run_main(args): cfg = load_config(args.config) if args.gpu is not None: cfg.resource.gpus = range(args.gpu) if args.cpu is not None: cfg.resource.cpu_per_gpu = args.cpu if args.epoch is not None: cfg.train.num_epoch = args.epoch app = gap.Application(cfg.application, **cfg.resource) if "format" in cfg: app.set_format(**cfg.format) app.load(**cfg.graph) app.build(**cfg.build) app.train(**cfg.train) if args.eval and "evaluate" in cfg: if isinstance(cfg.evaluate, dict): cfg.evaluate = [cfg.evaluate] for evaluation in cfg.evaluate: app.evaluate(**evaluation) if "save" in cfg: app.save_model(**cfg.save)