Example #1
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}")
Example #2
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}")
Example #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 = 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}")
Example #4
0
    aggregator_type_gene_space = [0, 1, 2, 3]
    activate_function_gene_space = [0, 1, 2, 3, 4, 5, 6, 7]
    number_of_heads_gene_space = [1, 2, 4, 6, 8, 16]
    hidden_units_gene_space = [4, 8, 16, 32, 64, 128, 256]
    gene_space = [
        attention_type_gene_space, aggregator_type_gene_space,
        activate_function_gene_space, number_of_heads_gene_space,
        hidden_units_gene_space, attention_type_gene_space,
        aggregator_type_gene_space, activate_function_gene_space,
        number_of_heads_gene_space
    ]
    num_genes = len(gene_space)
    mutation_type = "random"
    mutation_percent_genes = 10

    trnr = trainer.Trainer(args)
    ga_instance = pygad.GA(num_generations=num_generations,
                           num_parents_mating=num_parents_mating,
                           gene_type=int,
                           fitness_func=fitness_function,
                           sol_per_pop=sol_per_pop,
                           num_genes=num_genes,
                           gene_space=gene_space,
                           parent_selection_type=parent_selection_type,
                           keep_parents=keep_parents,
                           crossover_type=crossover_type,
                           mutation_type=mutation_type,
                           on_generation=callback_gen,
                           mutation_percent_genes=mutation_percent_genes)

    ga_instance.run()