本文整理汇总了Python中gym.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python gym.__version__方法的具体用法?Python gym.__version__怎么用?Python gym.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gym
的用法示例。
在下文中一共展示了gym.__version__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_env
# 需要导入模块: import gym [as 别名]
# 或者: from gym import __version__ [as 别名]
def make_env(args, seed, test):
if args.env.startswith('Roboschool'):
# Check gym version because roboschool does not work with gym>=0.15.6
from distutils.version import StrictVersion
gym_version = StrictVersion(gym.__version__)
if gym_version >= StrictVersion('0.15.6'):
raise RuntimeError('roboschool does not work with gym>=0.15.6')
import roboschool # NOQA
env = gym.make(args.env)
# Unwrap TimiLimit wrapper
assert isinstance(env, gym.wrappers.TimeLimit)
env = env.env
# Use different random seeds for train and test envs
env_seed = 2 ** 32 - 1 - seed if test else seed
env.seed(int(env_seed))
# Cast observations to float32 because our model uses float32
env = chainerrl.wrappers.CastObservationToFloat32(env)
# Normalize action space to [-1, 1]^n
env = chainerrl.wrappers.NormalizeActionSpace(env)
if args.monitor:
env = chainerrl.wrappers.Monitor(
env, args.outdir, force=True, video_callable=lambda _: True)
if args.render:
env = chainerrl.wrappers.Render(env, mode='human')
return env
示例2: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import __version__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False):
Wrapper.__init__(self, env=env)
self.tstart = time.time()
if filename is None:
self.f = None
self.logger = None
else:
if not filename.endswith(Monitor.EXT):
filename = filename + "." + Monitor.EXT
self.f = open(filename, "wt")
self.logger = JSONLogger(self.f)
self.logger.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
"env_id": env.spec.id if env.spec else 'Unknown'})
self.allow_early_resets = allow_early_resets
self.rewards = None
self.needs_reset = True
self.episode_rewards = []
self.episode_lengths = []
self.total_steps = 0
self.current_metadata = {} # extra info that gets injected into each log entry
# Useful for metalearning where we're modifying the environment externally
# But want our logs to know about these modifications
示例3: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import __version__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, cpu=None):
Wrapper.__init__(self, env=env)
self.tstart = time.time()
self.filename = filename
if filename is None:
self.f = None
self.logger = None
else:
if not filename.endswith(Monitor.EXT):
filename_local = filename + "." + Monitor.EXT_LOCAL
filename = filename + "." + Monitor.EXT
else:
filename_local = filename[:-13] + "." + Monitor.EXT_LOCAL
self.f = open(filename, "wt")
self.f_local = open(filename_local, "wt")
self.logger = JSONLogger(self.f, filename=filename)
self.logger_local = JSONLogger(self.f_local, override=True)
self.logger.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
"env_id": env.spec.id if env.spec else 'Unknown'})
self.logger_local.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
"env_id": env.spec.id if env.spec else 'Unknown'})
self.allow_early_resets = allow_early_resets
self.rewards = None
self.needs_reset = True
self.episode_rewards = []
self.episode_lengths = []
self.total_steps = 0
self.current_metadata = {} # extra info that gets injected into each log entry
# Useful for metalearning where we're modifying the environment externally
# But want our logs to know about these modifications
self.cpu = cpu
示例4: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import __version__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=()):
Wrapper.__init__(self, env=env)
self.tstart = time.time()
if filename is None:
self.f = None
self.logger = None
else:
if not filename.endswith(Monitor.EXT):
if osp.isdir(filename):
filename = osp.join(filename, Monitor.EXT)
else:
filename = filename + "." + Monitor.EXT
self.f = open(filename, "wt")
self.f.write('#%s\n'%json.dumps({"t_start": self.tstart, "gym_version": gym.__version__,
"env_id": env.spec.id if env.spec else 'Unknown'}))
self.logger = csv.DictWriter(self.f, fieldnames=('r', 'l', 't')+reset_keywords)
self.logger.writeheader()
self.reset_keywords = reset_keywords
self.allow_early_resets = allow_early_resets
self.rewards = None
self.needs_reset = True
self.episode_rewards = []
self.episode_lengths = []
self.total_steps = 0
self.current_reset_info = {} # extra info about the current episode, that was passed in during reset()
示例5: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import __version__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=()):
Wrapper.__init__(self, env=env)
self.tstart = time.time()
if filename is None:
self.f = None
self.logger = None
else:
if not filename.endswith(Monitor.EXT):
if osp.isdir(filename):
filename = osp.join(filename, Monitor.EXT)
else:
filename = filename + "." + Monitor.EXT
self.f = open(filename, "wt")
self.f.write('#%s\n'%json.dumps({"t_start": self.tstart, "gym_version": gym.__version__,
"env_id": env.spec.id if env.spec else 'Unknown'}))
self.logger = csv.DictWriter(self.f, fieldnames=('r', 'l', 't')+reset_keywords)
self.logger.writeheader()
self.reset_keywords = reset_keywords
self.allow_early_resets = allow_early_resets
self.rewards = None
self.needs_reset = True
self.episode_rewards = []
self.episode_lengths = []
self.total_steps = 0
self.current_reset_info = {} # extra info about the current episode, that was passed in during reset()
## Cambria specific
self.sensor_space = env.sensor_space