示例#1
0
def runExperiment(architecture, dataset, seed, max_evaluations, num_samples):
    from neuralbench.classification.dataset.create import run_validate_splits
    np.random.seed(seed)
    file_name = "backprop_%s_%s_%03d_e%010d_s%05d.dat" % (
        architecture, dataset["name"], seed, max_evaluations, num_samples)
    f = open(file_name, 'w')
    f.write("seed\ttest_split\tvalidation_split")
    f.write("\tevaluation_data\tevaluations\tfitness_type\tresult\n")

    subs = createArchitecture(architecture, dataset["name"])
    if dataset["name"] == "mnist":
        train_network = configure_for_training(num_samples, max_evaluations,
                                               10, subs, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)
    else:
        train_network = configure_for_training(num_samples, max_evaluations, 2,
                                               subs, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)

    f.close()
示例#2
0
def runExperiment(architecture, dataset, seed, max_evaluations, num_samples):
    from neuralbench.classification.dataset.create import run_validate_splits
    params = LeeaParams()
    params.parent_fitness_decay = 0.05
    params.mutation_power_decay = 0.99
    params.sexual_reproduction_proportion = 0.5
    params.population_size = 50
    params.starting_mutation_power = 0.3
    params.mutation_power = params.starting_mutation_power
    params.mutation_rate = 0.4
    params.selection_proportion = 0.4
    params.initial_weight_range = 4.
    params.batch_size = num_samples
    np.random.seed(seed)

    eval_genotype, weights_template = leeaNetworks.createArchitecture(
        architecture, dataset["name"])

    np.random.seed(seed)
    file_name = "leea_%s_%s_%03d_e%010d_s%05d.dat" % (
        architecture, dataset["name"], seed, max_evaluations, num_samples)
    f = open(file_name, 'w')
    f.write("seed\ttest_split\tvalidation_split")
    f.write(
        "\tpopulation_size\tmutation_power\tmutation_rate\tselection_proportion\tbatch_size\tinitial_weight_range"
    )
    f.write("\tevaluation_data\tevaluations\tfitness_type\tresult\n")

    if dataset["name"] == "mnist":
        train_network = configure_for_training(params, max_evaluations, 10,
                                               eval_genotype, weights_template,
                                               seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)
    else:
        train_network = configure_for_training(params, max_evaluations, 2,
                                               eval_genotype, weights_template,
                                               seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)

    f.close()
def runExperiment(architecture, dataset, seed, max_evaluations, num_samples):
    params = CosyneParams()
    params.population_size = 40
    params.mutation_power = 0.3
    params.mutation_rate = 0.4
    params.selection_proportion = 0.4
    params.initial_weight_range = 4.
    params.batch_size = num_samples
    np.random.seed(seed)
    file_name = "cosyne_%s_%s_%03d_e%010d_s%05d.dat" % (
        architecture, dataset["name"], seed, max_evaluations, num_samples)
    f = open(file_name, 'w')
    f.write("seed\ttest_split\tvalidation_split")
    f.write(
        "\tpopulation_size\tmutation_power\tmutation_rate\tselection_proportion\tbatch_size\tinitial_weight_range"
    )
    f.write("\tevaluation_data\tevaluations\tfitness_type\tresult\n")
    buildNet, num_network_weights = cosyneNetworks.createArchitecture(
        architecture, dataset["name"])
    if dataset["name"] == "mnist":
        from neuralbench.classification.dataset.create import run_validate_splits
        eval_genotype = buildNet(28 * 28, 10)
        train_network = configure_for_training(params, max_evaluations, 10,
                                               eval_genotype,
                                               num_network_weights, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)
    else:
        from neuralbench.classification.dataset.create import run_validate_splits
        eval_genotype = buildNet(2, 2)
        train_network = configure_for_training(params, max_evaluations, 2,
                                               eval_genotype,
                                               num_network_weights, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)

    f.close()
示例#4
0
def runExperiment(architecture,
                  dataset,
                  seed,
                  max_evaluations,
                  num_samples,
                  tanh=False):
    from neuralbench.classification.dataset.create import run_validate_splits
    np.random.seed(seed)
    file_name = "hyperneat_%s_%s_%03d_e%010d_s%05d.dat" % (
        architecture, dataset["name"], seed, max_evaluations, num_samples)
    if tanh:
        file_name = "hyperneattanh_%s_%s_%03d_e%010d_s%05d.dat" % (
            architecture, dataset["name"], seed, max_evaluations, num_samples)
    f = open(file_name, 'w')
    subs = createArchitecture(architecture, dataset["name"])

    set_activation_functions(tanh)

    if dataset["name"] == "mnist":
        train_network = configure_for_training(num_samples, max_evaluations,
                                               10, subs, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)
    else:
        train_network = configure_for_training(num_samples, max_evaluations, 2,
                                               subs, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)

    f.close()
示例#5
0
def runExperiment(dataset, seed, max_evaluations, num_samples, tanh=False):
    from neuralbench.classification.dataset.create import run_validate_splits
    np.random.seed(seed)
    file_name = "neat_neat_%s_%03d_e%010d_s%05d.dat" % (
        dataset["name"], seed, max_evaluations, num_samples)
    if tanh:
        file_name = "neattanh_neattanh_%s_%03d_e%010d_s%05d.dat" % (
            dataset["name"], seed, max_evaluations, num_samples)
    f = open(file_name, 'w')
    f.write("seed\ttest_split\tvalidation_split")
    f.write("\tevaluation_data\tevaluations\tfitness_type\tresult\n")

    if tanh: set_activation_functions()

    if dataset["name"] == "mnist":
        train_network = configure_for_training(num_samples, max_evaluations,
                                               10, seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)
    else:
        train_network = configure_for_training(num_samples, max_evaluations, 2,
                                               seed, f)
        run_validate_splits(train_network,
                            dataset["X_train"],
                            dataset["y_train"],
                            dataset["X_test"],
                            dataset["y_test"],
                            folds=10,
                            seed=seed)

    f.close()