本文整理匯總了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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