Ejemplo n.º 1
0
def run(problem, optimizer, n_calls, n_runs):
    if problem == "fc":
        problem = FCNetOnMnist()
        bounds = hpolib_to_skopt_bounds(problem)

    elif problem == "cnn":
        problem = ConvolutionalNeuralNetworkOnCIFAR10()
        bounds = hpolib_to_skopt_bounds(problem)

    elif problem == "lr":
        problem = LogisticRegressionOnMnist()
        bounds = hpolib_to_skopt_bounds(problem)
    else:
        raise ValueError("Problem should be either fc | cnn | lr")

    func = lambda x: problem.objective_function(configuration=x)[
        "function_value"]

    if optimizer == "gp":
        opt = gp_minimize
    elif optimizer == "forest":
        opt = forest_minimize

    min_vals = []
    for n_run in range(n_runs):
        res = opt(func,
                  bounds,
                  n_calls=n_calls,
                  n_random_starts=1,
                  verbose=1,
                  random_state=n_run)
        del res["specs"]
        dump(res, "%s_%d.pkl" % (optimizer, n_run))
        min_vals.append(res.fun)

    print(min_vals)
    return np.min(min_vals), np.std(min_vals)
Ejemplo n.º 2
0
    f = SvmOnMnist(rng=rng)
    num_iterations = 15
    output_path = "./experiments/fabolas/results/svm_%s/entropy_search_%d" % (
        dataset, run_id)
elif dataset == "vehicle":
    f = SvmOnVehicle(rng=rng)
    num_iterations = 15
    output_path = "./experiments/fabolas/results/svm_%s/entropy_search_%d" % (
        dataset, run_id)
elif dataset == "covertype":
    f = SvmOnCovertype(rng=rng)
    num_iterations = 15
    output_path = "./experiments/fabolas/results/svm_%s/entropy_search_%d" % (
        dataset, run_id)
elif dataset == "cifar10":
    f = ConvolutionalNeuralNetworkOnCIFAR10(rng=rng)
    num_iterations = 15
    output_path = "./experiments/fabolas/results/cnn_%s/entropy_search_%d" % (
        dataset, run_id)
elif dataset == "svhn":
    f = ConvolutionalNeuralNetworkOnSVHN(rng=rng)
    num_iterations = 15
    output_path = "./experiments/fabolas/results/cnn_%s/entropy_search_%d" % (
        dataset, run_id)
elif dataset == "res_net":
    f = ResidualNeuralNetworkOnCIFAR10(rng=rng)
    num_iterations = 10
    output_path = "./experiments/fabolas/results/res_%s/entropy_search_%d" % (
        dataset, run_id)

os.makedirs(output_path, exist_ok=True)