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


Python spaces.Box方法代码示例

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


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

示例1: step

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def step(self, action):
        if isinstance(self._wrapped_env.action_space, Box):
            # rescale the action
            lb, ub = self._wrapped_env.action_space.bounds
            scaled_action = lb + (action + 1.) * 0.5 * (ub - lb)
            scaled_action = np.clip(scaled_action, lb, ub)
        else:
            scaled_action = action
        wrapped_step = self._wrapped_env.step(scaled_action)
        next_obs, reward, done, info = wrapped_step
        info['orig_obs'] = next_obs
        if self._normalize_obs:
            next_obs = self._apply_normalize_obs(next_obs)
        if self._normalize_reward:
            reward = self._apply_normalize_reward(reward)
        return Step(next_obs, reward * self._scale_reward, done, **info) 
开发者ID:nosyndicate,项目名称:pytorchrl,代码行数:18,代码来源:normalized_env.py

示例2: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def __init__(
            self,
            *args,
            **kwargs):

        Serializable.quick_init(self, locals())
        MazeEnv.__init__(self, *args, **kwargs)
        self._blank_maze = False
        self.blank_maze_obs = np.concatenate([np.zeros(self._n_bins), np.zeros(self._n_bins)])

        # The following caches the spaces so they are not re-instantiated every time
        shp = self.get_current_obs().shape
        ub = BIG * np.ones(shp)
        self._observation_space = spaces.Box(ub * -1, ub)

        shp = self.get_current_robot_obs().shape
        ub = BIG * np.ones(shp)
        self._robot_observation_space = spaces.Box(ub * -1, ub)

        shp = self.get_current_maze_obs().shape
        ub = BIG * np.ones(shp)
        self._maze_observation_space = spaces.Box(ub * -1, ub) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:24,代码来源:fast_maze_env.py

示例3: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def action_space(self):
        if isinstance(self._wrapped_env.action_space, Box):
            ub = np.ones(self._wrapped_env.action_space.shape)
            return spaces.Box(-1 * ub, ub)
        return self._wrapped_env.action_space 
开发者ID:nosyndicate,项目名称:pytorchrl,代码行数:7,代码来源:normalized_env.py

示例4: __eq__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def __eq__(self, other):
        return (isinstance(other, Box) 
                and self.shape == other.shape
                and np.allclose(self.low, other.low) 
                and np.allclose(self.high, other.high) 
                and self.names == other.names) 
开发者ID:vicariousinc,项目名称:pixelworld,代码行数:8,代码来源:spaces_rllab.py

示例5: ensure_named

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def ensure_named(space):
    """Ensure that the give space is named."""
    if isinstance(space, (NamedBox, NamedDiscrete)):
        return space
    elif isinstance(space, Box):
        return NamedBox.from_unnamed(space)
    elif isinstance(space, Discrete):
        return NamedDiscrete.from_unnamed(space)
#    elif isinstance(space, ListSpace):
#        return NamedDiscrete(len(space._list), names=space._list)        
    else:
        raise Exception("Cannot convert space of type %s into a named rllab space"
            % (type(space),)) 
开发者ID:vicariousinc,项目名称:pixelworld,代码行数:15,代码来源:spaces_rllab.py

示例6: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def observation_space(self):
		return Box(np.array([-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -100.0, -100.0, -100.0]), np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0])) 
开发者ID:purdue-biorobotics,项目名称:flappy,代码行数:4,代码来源:fwmav_sim_env_maneuver.py

示例7: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def action_space(self):
        return Box(low=-np.ones(2), high=np.ones(2)) 
开发者ID:thanard,项目名称:me-trpo,代码行数:4,代码来源:point_mass_env.py

示例8: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def observation_space(self):
        return Box(low=np.concatenate([self.boundary[0]*np.ones(2),
                                       self.vel_bounds[0]*np.ones(2),
                                       self.boundary[0] * np.ones(2)]),
                   high=np.concatenate([self.boundary[1]*np.ones(2),
                                       self.vel_bounds[1]*np.ones(2),
                                       self.boundary[1] * np.ones(2)])) 
开发者ID:thanard,项目名称:me-trpo,代码行数:9,代码来源:point_mass_env.py

示例9: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def observation_space(self):
        return Box(low=-10*np.ones(2), high=10*np.ones(2)) 
开发者ID:thanard,项目名称:me-trpo,代码行数:4,代码来源:point2D_env.py

示例10: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def __init__(self, transition_matrix, reward, init_state, terminate_on_reward=False):
        super(DiscreteEnv, self).__init__()
        dX, dA, dXX = transition_matrix.shape
        self.nstates = dX
        self.nactions = dA
        self.transitions = transition_matrix
        self.init_state = init_state
        self.reward = reward
        self.terminate_on_reward = terminate_on_reward

        self.__observation_space = Box(0, 1, shape=(self.nstates,))
        #max_A = 0
        #for trans in self.transitions:
        #    max_A = max(max_A, len(self.transitions[trans]))
        self.__action_space = Discrete(dA) 
开发者ID:justinjfu,项目名称:inverse_rl,代码行数:17,代码来源:simple_env.py

示例11: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def __init__(self):
        self._action_space = spaces.Box(low=np.array([-1]), high=np.array([1]))
        self._observation_space = spaces.Box(low=np.array([-1,-1,0]), high=np.array([1,1,2]))
        self.reset() 
开发者ID:sisl,项目名称:hgail,代码行数:6,代码来源:envs.py

示例12: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def __init__(self, lows, highs, shapes=None):
        if shapes is None:
            assert len(lows) == len(highs)
            self.agent_num = len(lows)
            self.agent_spaces = np.array([Box(low, high) for low, high in zip(lows, highs)])
        else:
            assert len(lows) == len(highs) == len(shapes)
            self.agent_num = len(lows)
            self.agent_spaces = np.array([Box(low, high, shape) for low, high, shape in zip(lows, highs, shapes)]) 
开发者ID:ml3705454,项目名称:mapr2,代码行数:11,代码来源:space.py

示例13: latent_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def latent_space(self):
        return Box(low=-np.inf, high=np.inf, shape=(1,)) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:4,代码来源:categorical_mlp_policy.py

示例14: latent_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def latent_space(self):
        return Box(low=-np.inf, high=np.inf, shape=(1,))

    # the mean and var now also depend on the particular latents sampled 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:6,代码来源:snn_mlp_policy.py

示例15: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Box [as 别名]
def observation_space(self):
        return Box(low=-np.inf, high=np.inf, shape=(2,)) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:4,代码来源:multiMod2D_env.py


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