Example #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n',
                        '--name',
                        type=str,
                        required=True,
                        help="name of the model")
    parser.add_argument('-c',
                        '--config',
                        type=str,
                        default='./config/default.yaml',
                        help="yaml config file")
    parser.add_argument('-p',
                        '--chkpt',
                        type=str,
                        default=None,
                        help="path of checkpoint pt file")
    parser.add_argument('-d',
                        '--device',
                        type=str,
                        default="all",
                        help="override device ids")
    parser.add_argument('-g',
                        '--genotype',
                        type=str,
                        default=None,
                        help="override genotype file")
    args = parser.parse_args()

    config = Config(args.config)
    if utils.check_config(config, args.name):
        raise Exception("Config error.")
    conf_str = config.to_string()

    exp_root_dir = os.path.join('exp', args.name)
    convert_fn = custom_genotype_space_cvt
    search_kwargs = init_all_search(config,
                                    args.name,
                                    exp_root_dir,
                                    args.device,
                                    args.genotype,
                                    convert_fn=convert_fn)
    search(config=config.search, chkpt_path=args.chkpt, **search_kwargs)
Example #2
0
def main():
    parser = argparse.ArgumentParser(description='Proxyless-NAS augment')
    parser.add_argument('-n',
                        '--name',
                        type=str,
                        required=True,
                        help="name of the model")
    parser.add_argument('-c',
                        '--config',
                        type=str,
                        default='./config/default.yaml',
                        help="yaml config file")
    parser.add_argument('-p',
                        '--chkpt',
                        type=str,
                        default=None,
                        help="path of checkpoint pt file")
    parser.add_argument('-d',
                        '--device',
                        type=str,
                        default="all",
                        help="override device ids")
    parser.add_argument('-g',
                        '--genotype',
                        type=str,
                        default=None,
                        help="override genotype file")
    args = parser.parse_args()

    config = Config(args.config)
    if utils.check_config(config, args.name):
        raise Exception("Config error.")

    exp_root_dir = os.path.join('exp', args.name)
    augment_kwargs = init_all_augment(config, args.name, exp_root_dir,
                                      args.device, args.genotype)
    augment(config.augment, args.chkpt, **augment_kwargs)
Example #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n',
                        '--name',
                        type=str,
                        required=True,
                        help="name of the model")
    parser.add_argument('-c',
                        '--config',
                        type=str,
                        default='./config/default.yaml',
                        help="yaml config file")
    parser.add_argument('-p',
                        '--chkpt',
                        type=str,
                        default=None,
                        help="path of checkpoint pt file")
    parser.add_argument('-d',
                        '--device',
                        type=str,
                        default="all",
                        help="override device ids")
    args = parser.parse_args()

    config = Config(args.config)
    if utils.check_config(config, args.name):
        raise Exception("config error.")

    hp_space = build_hparam_space('hparams.json')
    tuner = build_hparam_tuner(config.tune.tuner, hp_space)

    def measure(hp):
        global trial_index
        Config.apply(config, hp)
        trial_name = '{}_{}'.format(args.name, trial_index)
        exp_root_dir = os.path.join('exp', trial_name)
        trial_index += 1
        try:
            search_kwargs = init_all_search(config,
                                            trial_name,
                                            exp_root_dir,
                                            args.device,
                                            convert_fn=None)
            best_top1, best_gt, gts = search(config.search, args.chkpt,
                                             **search_kwargs)
            score = best_top1
            error_no = 0
        except Exception as e:
            traceback.print_exc()
            score = 0
            error_no = 1
            logging.debug('trial {} failed with exit code: {}'.format(
                trial_index, error_no))

        result = {
            'score': score,
            'error_no': error_no,
        }
        return result

    tuner.tune(measure, n_trial=2000, early_stopping=100)