コード例 #1
0
ファイル: run.py プロジェクト: GDPlumb/ExpO
def run_fn(args, evaluate_explanation=True):

    np.random.seed()

    dataset = args[0]
    trial = args[1]
    depth = args[2]
    size = args[3]
    rate = args[4]
    reg = args[5]

    name = args2name(dataset, trial, depth, size, rate, reg)

    cwd = os.getcwd()

    os.makedirs(name)
    os.chdir(name)

    manager = "regression"
    source = DATASET_PATH + dataset + ".csv"
    shape = [size] * depth
    out = eval(manager,
               source,
               hidden_layer_sizes=shape,
               learning_rate=rate,
               regularizer="Causal1D",
               c=reg,
               stddev_reg=0.5,
               evaluate_explanation=evaluate_explanation,
               stop_on_loss=True)

    with open("out.json", "w") as f:
        json.dump(out, f)

    os.chdir(cwd)
コード例 #2
0
ファイル: run.py プロジェクト: GDPlumb/ExpO
def run_fn(trial, type, evaluate_explanation = True):

    np.random.seed()

    dataset = "msd"
    depth = 5
    size = 100
    rate = 0.001
    reg = 0.1

    name = args2name(dataset, trial, depth, size, rate, reg)

    cwd = os.getcwd()

    os.makedirs(name)
    os.chdir(name)

    manager = "msd"
    source =  DATASET_PATH
    shape = [size] * depth
    out, epoch = eval(manager, source,
           hidden_layer_sizes = shape,
           learning_rate = rate,
           regularizer = type, c = reg, stddev_reg = 0.5,
           evaluate_explanation = False,
           stop_on_loss = True,
           min_epochs = 10, stopping_epochs = 10)

    with open("out.json", "w") as f:
        json.dump(out, f)

    os.chdir(cwd)
    
    return epoch
コード例 #3
0
def run_fn(args, evaluate_explanation = True):

    np.random.seed()

    dataset = args[0]
    trial = args[1]
    depth = args[2]
    size = args[3]
    rate = args[4]

    name = args2name(dataset, trial, depth, size, rate)

    cwd = os.getcwd()

    os.makedirs(name)
    os.chdir(name)

    manager = "msd"
    source =  DATASET_PATH
    shape = [size] * depth
    out = eval(manager, source,
               hidden_layer_sizes = shape,
               learning_rate = rate,
               evaluate_explanation = evaluate_explanation,
               stop_on_loss = True,
               min_epochs = 10, stopping_epochs = 10)

    with open("out.json", "w") as f:
        json.dump(out, f)

    os.chdir(cwd)
コード例 #4
0
    p.map(run_fn, configs)
    p.close()
    p.join()

if flag_agg:

    agg = {}
    config = {}

    list_means = {}

    for reg in regs:
        mean_acc = 0.0
        mean_lime = 0.0
        for trial in trials:
            name = args2name(dataset, trial, depth, size, rate, reg)
            with open(name + "/out.json") as f:
                results = json.load(f)
            mean_acc += results["test_acc"]
            mean_lime += results["lime_causal_metric"][0]
        mean_acc /= len(trials)
        mean_lime /= len(trials)
        list_means[str(reg)] = [mean_acc, mean_lime]

    with open("results.json", "w") as f:
        json.dump(list_means, f)

if flag_run_baselines:

    def baseline(name):