本文整理汇总了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)
示例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)
示例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
示例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)
示例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),))
示例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]))
示例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))
示例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)]))
示例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))
示例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)
示例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()
示例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)])
示例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,))
示例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
示例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,))