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


Python gym.ObservationWrapper方法代码示例

本文整理汇总了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) 
开发者ID:chainer,项目名称:chainerrl,代码行数:19,代码来源:atari_wrappers.py

示例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) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:20,代码来源:dopamine_connector.py

示例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 = [] 
开发者ID:flyyufelix,项目名称:sonic_contest,代码行数:24,代码来源:atari_wrappers.py

示例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) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:9,代码来源:atari_wrappers.py

示例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) 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:11,代码来源:retro_wrappers.py

示例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)) 
开发者ID:mjacar,项目名称:pytorch-trpo,代码行数:9,代码来源:atari_wrapper.py

示例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) 
开发者ID:alibaba,项目名称:EasyRL,代码行数:14,代码来源:atari_wrapper.py

示例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) 
开发者ID:mila-iqia,项目名称:atari-representation-learning,代码行数:7,代码来源:envs.py

示例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) 
开发者ID:keiohta,项目名称:tf2rl,代码行数:6,代码来源:atari_wrapper.py

示例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) 
开发者ID:tensorflow,项目名称:tensor2tensor,代码行数:17,代码来源:player_utils.py

示例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) 
开发者ID:Stable-Baselines-Team,项目名称:stable-baselines,代码行数:13,代码来源:atari_wrappers.py


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