本文整理汇总了Python中gym.ObservationWrapper方法的典型用法代码示例。如果您正苦于以下问题:Python gym.ObservationWrapper方法的具体用法?Python gym.ObservationWrapper怎么用?Python gym.ObservationWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gym
的用法示例。
在下文中一共展示了gym.ObservationWrapper方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env, channel_order='hwc'):
"""Warp frames to 84x84 as done in the Nature paper and later work.
To use this wrapper, OpenCV-Python is required.
"""
if not _is_cv2_available:
raise RuntimeError('Cannot import cv2 module. Please install OpenCV-Python to use WarpFrame.') # NOQA
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
shape = {
'hwc': (self.height, self.width, 1),
'chw': (1, self.height, self.width),
}
self.observation_space = spaces.Box(
low=0, high=255,
shape=shape[channel_order], dtype=np.uint8)
示例2: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env, size=84):
"""Based on WarpFrame from openai baselines atari_wrappers.py.
Dopamine also uses cv2.resize(..., interpolation=cv2.INTER_AREA).
Args:
env: TODO(konradczechowski): Add doc-string.
size: TODO(konradczechowski): Add doc-string.
"""
gym.ObservationWrapper.__init__(self, env)
self.width = size
self.height = size
assert env.observation_space.dtype == np.uint8
self.observation_space = spaces.Box(
low=0,
high=255,
shape=(self.height, self.width, env.observation_space.shape[2]),
dtype=np.uint8)
示例3: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
"""Warp frames to 84x84 as done in the Nature paper and later work."""
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
self.observation_space = spaces.Box(low=0, high=255,
shape=(self.height, self.width, 1), dtype=np.uint8)
#print("Load Keras Model!!!")
# Load Keras model
#self.json_name = './retro-movies/architecture_level_classifier_v5.json'
#self.weight_name = './retro-movies/model_weights_level_classifier_v5.h5'
#self.levelcls_model = model_from_json(open(self.json_name).read())
#self.levelcls_model.load_weights(self.weight_name, by_name=True)
##self.levelcls_model.load_weights(self.weight_name)
#print("Done Loading Keras Model!!!")
#self.mean_pixel = [103.939, 116.779, 123.68]
#self.warmup = 1000
#self.interval = 500
#self.counter = 0
#self.num_inference = 0
#self.max_inference = 5
self.level_pred = []
示例4: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
"""Warp frames to 84x84 as done in the Nature paper and later work."""
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
self.observation_space = spaces.Box(low=0, high=255,
shape=(self.height, self.width, 1), dtype=np.uint8)
示例5: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env, ratio):
"""
Downsample images by a factor of ratio
"""
gym.ObservationWrapper.__init__(self, env)
(oldh, oldw, oldc) = env.observation_space.shape
newshape = (oldh//ratio, oldw//ratio, oldc)
self.observation_space = spaces.Box(low=0, high=255,
shape=newshape, dtype=np.uint8)
示例6: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
"""Warp frames to 84x84 as done in the Nature paper and later work."""
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
self.observation_space = spaces.Box(
low=0, high=255, shape=(self.height, self.width, 1))
示例7: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env, frame_resize):
"""
Warp frames to 84x84 as done in the Nature paper and later work.
"""
gym.ObservationWrapper.__init__(self, env)
self.width = frame_resize
self.height = frame_resize
self.observation_space = spaces.Box(
low=0,
high=255,
shape=(self.height, self.width, 1),
dtype=np.uint8)
示例8: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
gym.ObservationWrapper.__init__(self, env)
self.observation_space = spaces.Box(low=0, high=255,
shape=(self.observation_space.shape[0], self.observation_space.shape[1], 1),
dtype=np.uint8)
示例9: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
gym.ObservationWrapper.__init__(self, env)
self.observation_space = gym.spaces.Box(
low=0, high=1, shape=env.observation_space.shape, dtype=np.float32)
示例10: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
gym.ObservationWrapper.__init__(self, env)
orig_shape = env.observation_space.shape
extended_shape = list(orig_shape)
for axis in self.HW_AXES:
if self.if_odd(orig_shape[axis]):
extended_shape[axis] += 1
assert env.observation_space.dtype == np.uint8
self.observation_space = gym.spaces.Box(
low=0,
high=255,
shape=extended_shape,
dtype=np.uint8)
示例11: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import ObservationWrapper [as 别名]
def __init__(self, env):
"""
Warp frames to 84x84 as done in the Nature paper and later work.
:param env: (Gym Environment) the environment
"""
gym.ObservationWrapper.__init__(self, env)
self.width = 84
self.height = 84
self.observation_space = spaces.Box(low=0, high=255, shape=(self.height, self.width, 1),
dtype=env.observation_space.dtype)