Exemplo n.º 1
0
def main(args):  # pylint:disable=redefined-outer-name

    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False

    # Set the random seed for the program
    torch.manual_seed(args.random_seed)
    np.random.seed(args.random_seed)
    np.set_printoptions(precision=8)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)

    utils.makedirs(args.dataset)
    search_space, action_list, submodel_manager = \
        build_search_space(args)

    if args.optimizer == 'EA':
        model_selector = EA_Selector(args, search_space, action_list,
                                     submodel_manager)
    elif args.optimizer == 'RL':
        model_selector = RL_Selector(args, search_space, action_list,
                                     submodel_manager)
    elif args.optimizer == 'GS':
        model_selector = GridSearch_Selector(args, search_space, action_list,
                                             submodel_manager)
    elif args.optimizer == 'RS':
        model_selector = RandomSearch_Selector(args, search_space, action_list,
                                               submodel_manager)
    else:
        raise Exception("[!] Optimizer not found: ", args.optimizer)
        exit(1)

    print('on selector main: ', args)
    model_selector.select()
Exemplo n.º 2
0
def main(args):  # pylint:disable=redefined-outer-name

    # os.environ['CUDA_VISIBLE_DEVICE'] = args.device
    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False
        print("CUDA NOT AVAILABLE!")
    # args.max_epoch = 1
    # args.controller_max_step = 1
    # args.derive_num_sample = 1
    torch.manual_seed(args.random_seed)
    if args.cuda:
        # print("Device Num", torch.cuda.current_device())
        torch.cuda.manual_seed(args.random_seed)

    utils.makedirs(args.dataset)

    trnr = trainer.Trainer(args)

    if args.mode == 'train':
        print(args)
        trnr.train()
    elif args.mode == 'derive':
        trnr.derive()
    else:
        raise Exception(f"[!] Mode not found: {args.mode}")
Exemplo n.º 3
0
def main(args):  # pylint:disable=redefined-outer-name

    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False
    # args.max_epoch = 10
    # args.controller_max_step = 1
    # args.derive_num_sample = 1
    torch.manual_seed(args.random_seed)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)

    # 创建包含数据集Citeseer名称目录
    utils.makedirs(args.dataset)
    """
    def makedirs(path):
    if not os.path.exists(path):
        logger.info("[*] Make directories : {}".format(path))
        os.makedirs(path)
    """

    #训练入口,获取最终GNN入口
    trnr = trainer.Trainer(args)

    if args.mode == 'train':
        print(args)
        trnr.train()
    elif args.mode == 'derive':
        trnr.derive()
    else:
        raise Exception(f"[!] Mode not found: {args.mode}")
Exemplo n.º 4
0
def main(args):  # pylint:disable=redefined-outer-name

    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False

    torch.manual_seed(args.random_seed)
    np.random.seed(args.random_seed)
    np.set_printoptions(precision=8)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)

    utils.makedirs(args.dataset)

    if args.optimizer == 'EA':
        trainer = Evolution_Trainer(args)
    elif args.optimizer == 'RL':
        trainer = RL_Trainer(args)
    elif args.optimizer == 'GS':
        trainer = GridSearch_Trainer(args)
    elif args.optimizer == 'RS':
        trainer = RandomSearch_Trainer(args)
    else:
        raise Exception("[!] Optimizer not found: ", args.optimizer)

    if args.mode == 'train':
        print(args)
        trainer.train()
    elif args.mode == 'derive':
        trainer.derive()
    else:
        raise Exception("[!] Mode not found: ", args.mode)
Exemplo n.º 5
0
    def __init__(self, args):
        if args.cuda and not torch.cuda.is_available():
            args.cuda = False

        torch.manual_seed(args.random_seed)
        np.random.seed(args.random_seed)
        np.set_printoptions(precision=8)

        if args.cuda:
            torch.cuda.manual_seed(args.random_seed)
        utils.makedirs(args.dataset)
        trainer = Evolution_Trainer(args)
        trainer.train()
Exemplo n.º 6
0
def main(args):  # pylint:disable=redefined-outer-name

    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False

    torch.manual_seed(args.random_seed)
    np.random.seed(args.random_seed)
    np.set_printoptions(precision=8)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)

    utils.makedirs(args.dataset)

    trainer = Evolution_Trainer(args)

    trainer.train()
Exemplo n.º 7
0
def main(args):  # pylint:disable=redefined-outer-name

    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False
    # args.max_epoch = 1
    # args.controller_max_step = 1
    # args.derive_num_sample = 1
    torch.manual_seed(args.random_seed)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)

    utils.makedirs(args.dataset)

    trnr = trainer.Trainer(args)

    if args.mode == 'train':
        print(args)
        trnr.train()
    elif args.mode == 'derive':
        trnr.derive()
    else:
        raise Exception(f"[!] Mode not found: {args.mode}")
Exemplo n.º 8
0
def fitness_func(solution, solution_idx):
    args = build_args()
    if args.cuda and not torch.cuda.is_available():  # cuda is not available
        args.cuda = False
    torch.manual_seed(args.random_seed)
    if args.cuda:
        torch.cuda.manual_seed(args.random_seed)
    utils.makedirs(args.dataset)
    global trnr

    search_space = MacroSearchSpace().search_space
    gnn = []
    gnn.append(search_space['attention_type'][int(solution[0])])
    gnn.append(search_space['aggregator_type'][int(solution[1])])
    gnn.append(search_space['activate_function'][int(solution[2])])
    gnn.append(int(solution[3]))
    gnn.append(int(solution[4]))
    gnn.append(search_space['attention_type'][int(solution[5])])
    gnn.append(search_space['aggregator_type'][int(solution[6])])
    gnn.append(search_space['activate_function'][int(solution[7])])
    gnn.append(int(solution[8]))
    gnn.append(6)
    fitness = trnr.genetic_get_reward(gnn)[1]
    return fitness
Exemplo n.º 9
0
    args1 = Parameter(method1)
    args2 = Parameter(method2)
    args3 = Parameter(method3)

    if args1.cuda and not torch.cuda.is_available():
        args1.cuda = False

    torch.manual_seed(args1.random_seed)
    np.random.seed(args1.random_seed)
    np.set_printoptions(precision=8)

    if args1.cuda:
        torch.cuda.manual_seed(args1.random_seed)

    utils.makedirs(args1.dataset)

    trainer1 = Evolution_Trainer.remote(args1)
    trainer2 = Evolution_Trainer.remote(args2)
    trainer3 = Evolution_Trainer.remote(args3)

    initialize_pop1, initialize_acc1 = trainer1.initialize_population_Random.remote(
    )
    initialize_pop2, initialize_acc2 = trainer2.initialize_population_Random.remote(
    )
    initialize_pop3, initialize_acc3 = trainer3.initialize_population_Random.remote(
    )

    task1 = [initialize_pop1, initialize_acc1]
    task2 = [initialize_pop2, initialize_acc2]
    task3 = [initialize_pop3, initialize_acc3]