示例#1
0
    mpiexec -n <num_nodes> python -m mpi4py.futures mpi\mpi_bagging.py
    will create 1 dispatcher node with rank 0 and num_node-1 workers for the pool

    """

    ## generate Training set, Test set & V_0s
    X_train, y_train = generate_train_set(Config.N_train, Config.Delta,
                                          Config.d)
    X_test, y_test = generate_test_set(Config.N_test, Config.Delta, Config.d)

    V_0_train = generate_V_0(Config.N_train, Config.Delta, Config.d)
    V_0_test = generate_V_0(Config.N_test, Config.Delta, Config.d)

    logger.info(f"V_0_test = {V_0_test}")

    reference = create_GPR(Config.N_train)
    reference.fit(X_train, y_train)
    f_X = reference.predict(X_test)
    reference_error = normalized_error_VT(f_X, y_test, V_0_test)
    logger.info(f"reference error : {reference_error}")

    ## MPI execute
    results = []

    with MPIPoolExecutor() as executor:
        futures = []
        # evaluate model for all points in grid by creating new mpi node
        for r in Config.Ratios:
            logger.info(f"starting evaluation for ratio {r}")
            future = executor.submit(evaluate_boosting,
                                     X_train.copy(),
示例#2
0
## create logger

logger = generate_logger_MPI(LOGFILE, LOGLEVEL, rank)
logger.info(f"node with rank {rank} started")

if rank == 0:
    """
    executed by main MPI process 
    
    mpiexec -n <num_nodes> python -m mpi4py.futures mpi\mpi_bagging.py
    will create 1 dispatcher node with rank 0 and num_node-1 workers for the pool

    """

    ## generate model
    gpr = create_GPR(Config.N_train)
    model = SimpleBagger(1, 1, gpr)

    ## generate Training set & V_0
    X_train, y_train = generate_train_set(Config.N_train, Config.Delta,
                                          Config.d)
    V_0 = generate_V_0(100000, Config.Delta, Config.d)
    logger.info(f"V_0 = {V_0}")

    ## MPI execute
    results = []
    with MPIPoolExecutor() as executor:
        futures = []
        # evaluate model for all points in grid by creating new mpi node
        for m in Config.M_grid:
            for alpha in Config.alpha_grid: