当前位置: 首页>>代码示例>>Python>>正文


Python wrappers.Vectorize方法代码示例

本文整理汇总了Python中universe.wrappers.Vectorize方法的典型用法代码示例。如果您正苦于以下问题:Python wrappers.Vectorize方法的具体用法?Python wrappers.Vectorize怎么用?Python wrappers.Vectorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在universe.wrappers的用法示例。


在下文中一共展示了wrappers.Vectorize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id):
    env = gym.make(env_id)
    env = Vectorize(env)
    env = AtariRescale42x42(env)
    env = DiagnosticsInfo(env)
    env = Unvectorize(env)
    return env 
开发者ID:YuhangSong,项目名称:DHP,代码行数:9,代码来源:envs.py

示例2: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id):
    env = gym.make(env_id)
    if len(env.observation_space.shape) > 1:
        print('Preprocessing env')
        env = Vectorize(env)
        env = AtariRescale42x42(env)
        env = NormalizedEnv(env)
        env = Unvectorize(env)
    else:
        print('No preprocessing because env is too small')
    return env 
开发者ID:atgambardella,项目名称:pytorch-es,代码行数:13,代码来源:envs.py

示例3: __init__

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def __init__(self, env):
        super(Wrapper, self).__init__(env)
        if not env.metadata.get('runtime.vectorized'):
            if self.autovectorize:
                # Circular dependency :(
                from universe import wrappers
                env = wrappers.Vectorize(env)
            else:
                raise error.Error('This wrapper can only wrap vectorized envs (i.e. where env.metadata["runtime.vectorized"] = True), not {}. Set "self.autovectorize = True" to automatically add a Vectorize wrapper.'.format(env))

        self.env = env 
开发者ID:openai,项目名称:universe,代码行数:13,代码来源:core.py

示例4: make_environment

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def make_environment(name, **args):
    """Make an environment of a given name, possibly using extra arguments."""
    env = environment_registry.get(name, Environment)
    if name in environment_registry:
        env = env(**args)
    else:
        env = env(name, **args)
    if "atari.atari_env" in env.unwrapped.__module__:
        to_dict = env.to_dict
        env = Vectorize(env)
        env = AtariRescale42x42(env)
        env = Unvectorize(env)
        env.to_dict = to_dict
    return env 
开发者ID:arnomoonens,项目名称:DeepRL,代码行数:16,代码来源:registration.py

示例5: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id):
    env = gym.make(env_id)
    if len(env.observation_space.shape) > 1:
        env = Vectorize(env)
        env = Unvectorize(env)
    return env

# process each frame 
开发者ID:andrewliao11,项目名称:pytorch-a3c-mujoco,代码行数:10,代码来源:envs.py

示例6: create_mario

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_mario(env_id, client_id, envWrap=True, record=False, outdir=None,
                    noLifeReward=False, acRepeat=0, **_):
    import ppaquette_gym_super_mario
    from ppaquette_gym_super_mario import wrappers
    if '-v' in env_id.lower():
        env_id = 'ppaquette/' + env_id
    else:
        env_id = 'ppaquette/SuperMarioBros-1-1-v0'  # shape: (224,256,3)=(h,w,c)

    # Mario workaround: Simultaneously launching multiple vizdoom processes makes program stuck,
    # so use the global lock in multi-threading/multi-processing
    # see: https://github.com/ppaquette/gym-super-mario/tree/master/ppaquette_gym_super_mario
    client_id = int(client_id)
    time.sleep(client_id * 50)
    env = gym.make(env_id)
    modewrapper = wrappers.SetPlayingMode('algo')
    acwrapper = wrappers.ToDiscrete()
    env = modewrapper(acwrapper(env))
    env = env_wrapper.MarioEnv(env)

    if record and outdir is not None:
        env = gym.wrappers.Monitor(env, outdir, force=True)

    if envWrap:
        frame_skip = acRepeat if acRepeat>0 else 6
        fshape = (42, 42)
        env.seed(None)
        if noLifeReward:
            env = env_wrapper.NoNegativeRewardEnv(env)
        env = env_wrapper.BufferedObsEnv(env, skip=frame_skip, shape=fshape, maxFrames=False)
        if frame_skip > 1:
            env = env_wrapper.SkipEnv(env, skip=frame_skip)
    elif noLifeReward:
        env = env_wrapper.NoNegativeRewardEnv(env)

    env = Vectorize(env)
    env = DiagnosticsInfo(env)
    env = Unvectorize(env)
    # env.close() # TODO: think about where to put env.close !
    return env 
开发者ID:pathak22,项目名称:noreward-rl,代码行数:42,代码来源:envs.py

示例7: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id, record=False, outdir=None, **_):
    env = gym.make(env_id)
    if record and outdir is not None:
        env = gym.wrappers.Monitor(env, outdir, force=True)
    env = Vectorize(env)
    env = AtariRescale42x42(env)
    env = DiagnosticsInfo(env)
    env = Unvectorize(env)
    return env 
开发者ID:pathak22,项目名称:noreward-rl,代码行数:11,代码来源:envs.py

示例8: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id):
  env = gym.make(env_id)
  env = Vectorize(env)
  env = AtariRescale42x42(env)
  env = DiagnosticsInfo(env)
  env = Unvectorize(env)
  env.runner = RunnerThread(env, 20)
  return env 
开发者ID:carpedm20,项目名称:a3c-tensorflow,代码行数:10,代码来源:atari.py

示例9: create_atari_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_atari_env(env_id):
    env = gym.make(env_id)
    if len(env.observation_space.shape) > 1:
        env = Vectorize(env)
        env = AtariRescale42x42(env)
        env = NormalizedEnv(env)
        env = Unvectorize(env)
    return env 
开发者ID:tpbarron,项目名称:pytorch-a2c,代码行数:10,代码来源:envs.py

示例10: create_car_racing_env

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_car_racing_env():
    env = gym.make('CarRacing-v0')
    env = Vectorize(env)
    env = CarRacingRescale32x32(env)
    env = NormalizedEnv(env)
    env = CarRacingDiscreteActions(env)
    env = Unvectorize(env)
    return env 
开发者ID:tpbarron,项目名称:pytorch-a2c,代码行数:10,代码来源:envs.py

示例11: create_doom

# 需要导入模块: from universe import wrappers [as 别名]
# 或者: from universe.wrappers import Vectorize [as 别名]
def create_doom(env_id, client_id, envWrap=True, record=False, outdir=None,
                    noLifeReward=False, acRepeat=0, **_):
    from ppaquette_gym_doom import wrappers
    if 'labyrinth' in env_id.lower():
        if 'single' in env_id.lower():
            env_id = 'ppaquette/LabyrinthSingle-v0'
        elif 'fix' in env_id.lower():
            env_id = 'ppaquette/LabyrinthManyFixed-v0'
        else:
            env_id = 'ppaquette/LabyrinthMany-v0'
    elif 'very' in env_id.lower():
        env_id = 'ppaquette/DoomMyWayHomeFixed15-v0'
    elif 'sparse' in env_id.lower():
        env_id = 'ppaquette/DoomMyWayHomeFixed-v0'
    elif 'fix' in env_id.lower():
        if '1' in env_id or '2' in env_id:
            env_id = 'ppaquette/DoomMyWayHomeFixed' + str(env_id[-2:]) + '-v0'
        elif 'new' in env_id.lower():
            env_id = 'ppaquette/DoomMyWayHomeFixedNew-v0'
        else:
            env_id = 'ppaquette/DoomMyWayHomeFixed-v0'
    else:
        env_id = 'ppaquette/DoomMyWayHome-v0'

    # VizDoom workaround: Simultaneously launching multiple vizdoom processes
    # makes program stuck, so use the global lock in multi-threading/processing
    client_id = int(client_id)
    time.sleep(client_id * 10)
    env = gym.make(env_id)
    modewrapper = wrappers.SetPlayingMode('algo')
    obwrapper = wrappers.SetResolution('160x120')
    acwrapper = wrappers.ToDiscrete('minimal')
    env = modewrapper(obwrapper(acwrapper(env)))
    # env = env_wrapper.MakeEnvDynamic(env)  # to add stochasticity

    if record and outdir is not None:
        env = gym.wrappers.Monitor(env, outdir, force=True)

    if envWrap:
        fshape = (42, 42)
        frame_skip = acRepeat if acRepeat>0 else 4
        env.seed(None)
        if noLifeReward:
            env = env_wrapper.NoNegativeRewardEnv(env)
        env = env_wrapper.BufferedObsEnv(env, skip=frame_skip, shape=fshape)
        env = env_wrapper.SkipEnv(env, skip=frame_skip)
    elif noLifeReward:
        env = env_wrapper.NoNegativeRewardEnv(env)

    env = Vectorize(env)
    env = DiagnosticsInfo(env)
    env = Unvectorize(env)
    return env 
开发者ID:pathak22,项目名称:noreward-rl,代码行数:55,代码来源:envs.py


注:本文中的universe.wrappers.Vectorize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。