def run(name, params_dict, mu=0.0):
    simulation_parameters = get_implicit_lasso_simulation(**params_dict)

    # Add mu attribute to simulation_parameters.
    setattr(simulation_parameters, 'mu', mu)
    # Add a correlation matrix if mu is not 0.0.
    if mu != 0.0:
        simulation_parameters.covariates_kwargs_dict['covariance_matrix'] = \
            mu * np.ones((d, d)) + (1.0 - mu) * np.identity(d)

    start = time.time()

    results = core.run_in_parallel(
        runs_per_device,
        processes_per_device,
        simulation_parameters,
        pytorch_configs)

    # Do not save the covariance matrix.
    simulation_parameters.covariates_kwargs_dict = {}

    utils.save_simulation_output(
        simulation_name, results, simulation_parameters)
    end = time.time()
    print("Execution time for id: ", run_id, ":",
          end - start, "seconds.")
def run(name, params_dict):
    simulation_parameters = get_implicit_lasso_simulation(**params_dict)
    start = time.time()
    results = core.run_in_parallel(runs_per_device, processes_per_device,
                                   simulation_parameters, pytorch_configs)
    utils.save_simulation_output(simulation_name, results,
                                 simulation_parameters)
    end = time.time()
    print("Execution time for id: ", run_id, ":", end - start, "seconds.")
Esempio n. 3
0
def run(name, params_dict, paths_simulation=False):
    simulation_parameters = get_implicit_lasso_simulation(**params_dict)
    start = time.time()

    if paths_simulation:
        # This is the last simulation, the one used for plotting gd and
        # lasso paths.
        results = core.run_in_parallel(
            1,
            1,
            simulation_parameters,
            [pytorch_configs[0]])
    else:
        results = core.run_in_parallel(
            runs_per_device,
            processes_per_device,
            simulation_parameters,
            pytorch_configs)

    utils.save_simulation_output(
        simulation_name, results, simulation_parameters)
    end = time.time()
    print("Execution time for id: ", run_id, ":",
          end - start, "seconds.")
            simulation_name = output_dir + "alphas/run_" + str(run_id)
            simulation_parameters = get_implicit_lasso_simulation(
                alpha=alpha,
                observe_parameters=0,
                noise_std=noise_std,
                observers_frequency=10,
                run_glmnet=0,
                store_glmnet_path=0,
                **default_params)
            # Start our simulations.
            start = time.time()
            results = core.run_in_parallel(runs_per_device,
                                           processes_per_device,
                                           simulation_parameters,
                                           pytorch_configs)
            utils.save_simulation_output(simulation_name, results,
                                         simulation_parameters)
            end = time.time()
            print("Execution time for id: ", run_id, ":", end - start,
                  "seconds.")
            run_id += 1

    # Now we perform simulatinos for saving the parameter paths.
    alphas = 10.0**(np.array([-3.0, -12.0]))
    run_id = 0
    print("Starting simulations for saving parameter paths")
    for alpha in alphas:
        for noise_std in noise_stds:
            simulation_name = output_dir + "paths/run_" + str(run_id)
            simulation_parameters = get_implicit_lasso_simulation(
                alpha=alpha,
                noise_std=noise_std,