예제 #1
0
def get_experiment_environment(**args):
    from utils import setup_mpi_gpus, setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    setup_mpi_gpus()

    tf_context = setup_tensorflow_session()
    return tf_context
예제 #2
0
def get_experiment_environment(**args):
    from utils import setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * 0
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)

    logger_context = logger.scoped_configure(
        dir=None, format_strs=['stdout', 'log', 'csv'])
    tf_context = setup_tensorflow_session()
    return logger_context, tf_context
예제 #3
0
def get_experiment_environment(**args):
    from utils import setup_mpi_gpus, setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    setup_mpi_gpus()

    logger_context = logger.scoped_configure(dir=args['env'],
                                             format_strs=['stdout', 'log',
                                                          'csv'] if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])
    tf_context = setup_tensorflow_session()
    return logger_context, tf_context
예제 #4
0
def get_experiment_environment(**args):
    process_seed = 1234 + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(1234)
    setup_mpi_gpus()

    logger_context = logger.scoped_configure(
        dir='C:/Users/Elias/Desktop/savedunc/' + MODE + '_' +
        datetime.now().strftime('%Y_%m_%d_%H_%M_%S'),
        format_strs=['stdout', 'log', 'csv', 'tensorboard']
        if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])

    tf_context = setup_tensorflow_session()
    return logger_context, tf_context
예제 #5
0
def get_experiment_environment(**args):
    from utils import setup_mpi_gpus, setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    setup_mpi_gpus()
    logdir = './' + args["logdir"] + '/' + datetime.datetime.now().strftime(
        args["expID"] + "-openai-%Y-%m-%d-%H-%M-%S-%f")
    logger_context = logger.scoped_configure(
        dir=logdir,
        format_strs=['stdout', 'log', 'csv', 'tensorboard']
        if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])
    tf_context = setup_tensorflow_session()
    return logger_context, tf_context, logdir
def get_experiment_environment(**args):
    log_directory = osp.join(
        './output/' +
        datetime.datetime.now().strftime("openai-%Y-%m-%d-%H-%M-%S-%f"))
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    # TODO: turn this back up when have GPU support!
    # setup_mpi_gpus()

    logger_context = logger.scoped_configure(
        dir=log_directory,
        format_strs=['stdout', 'log', 'csv']
        if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])
    tf_context = setup_tensorflow_session()
    return logger_context, tf_context
예제 #7
0
def play_experiment(**args):
    # 该函数在本文件中定义. 对不同的环境进行各种 wrapper. 这是一个函数, 并没有真正初始化环境
    make_env = partial(make_env_all_params, args=args)

    # 初始化
    tester = Tester(make_env=make_env,
                    num_timesteps=args['num_timesteps'],
                    hps=args,
                    envs_per_process=1)

    from utils import setup_tensorflow_session
    tf_sess = setup_tensorflow_session()
    saver = tf.train.Saver()

    # model_path
    model_path = args['model_path']

    with tf_sess:
        tester.play(tf_sess, args, saver, model_path)
예제 #8
0
def get_experiment_environment(**args):
    from utils import setup_mpi_gpus, setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    setup_mpi_gpus()

    time = datetime.datetime.now().strftime("%m-%d-%H-%M-%S")
    path_with_args = './logs/' + '_'.join([
        time, args['exp_name'], args['env_kind'], args['feature_space'],
        str(args['envs_per_process']),
        str(args['train_discriminator']),
        str(args['discriminator_weighted'])
    ])

    format_strs = ['stdout', 'log', 'csv', 'tensorboard'
                   ] if MPI.COMM_WORLD.Get_rank() == 0 else ['log']
    logger_context = logger.scoped_configure(dir=path_with_args,
                                             format_strs=format_strs)
    tf_context = setup_tensorflow_session()
    return logger_context, tf_context
예제 #9
0
def get_experiment_environment(**args):
    # 初始化 MPI 相关的量
    from utils import setup_mpi_gpus, setup_tensorflow_session
    from baselines.common import set_global_seeds
    from gym.utils.seeding import hash_seed
    process_seed = args["seed"] + 1000 * MPI.COMM_WORLD.Get_rank()
    process_seed = hash_seed(process_seed, max_bytes=4)
    set_global_seeds(process_seed)
    setup_mpi_gpus()

    logger_dir = './logs/' + datetime.datetime.now().strftime(
        args["env"] + "-" + args["reward_type"] + "-" +
        str(args["nepochs_dvae"]) + "-" + str(args["stickyAtari"]) +
        "-%Y-%m-%d-%H-%M-%S-%f")
    logger_context = logger.scoped_configure(
        dir=logger_dir,
        format_strs=['stdout', 'log', 'csv']
        if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])
    tf_context = setup_tensorflow_session()

    # bai.      新增 saver 用于保存权重
    saver = tf.train.Saver()
    return logger_context, tf_context, saver, logger_dir
예제 #10
0
파일: run.py 프로젝트: sahanayvaz/rss
def start_experiment(**args):
    # create environment
    # coinrun environment is already vectorized
    env, test_env = make_env_all_params(args=args)

    # set random seeds for reproducibility
    utils.set_global_seeds(seed=args['seed'])

    # create tf.session
    tf_sess = utils.setup_tensorflow_session()

    if args['server_type'] == 'local':
        logger_context = logger.scoped_configure(dir=args['log_dir'],
                                                 format_strs=['stdout', 'csv'])
    else:
        logger_context = logger.scoped_configure(dir=args['log_dir'],
                                                 format_strs=['csv'])

    with logger_context, tf_sess:
        print("logging directory: {}".format(args['log_dir']))

        # create trainer
        trainer = Trainer(env=env, test_env=test_env, args=args)

        if args['evaluation'] == 1:
            # load_path is changed to model_path
            print('run.py, def start_experiment, evaluating model: {}'.format(
                args['load_path']))
            trainer.eval()

        # this is for visualizing the loss landscape
        elif args['visualize'] == 1:
            print('running visualization...')
            trainer.visualize()
        else:
            print('run.py, def start_experiment, training begins...')
            trainer.train()