我试着跑
cleanrl
上
Pendulum-v1
环境我做到了
here
和更改默认值
env-id
到
parser.add_argument("--env-id", type=str, default="Pendulum-v1",help="the id of the environment")
然而,我不断地得到错误-
NotImplementedError: Box([-1. -1. -8.], [1. 1. 8.], (3,), <class 'numpy.float32'>) observation space is not supported
因此,我将此错误调试到从导入的ReplayBuffer
SB3
。这是
problem function
-
def get_obs_shape(
observation_space: spaces.Space,
) -> Union[Tuple[int, ...], Dict[str, Tuple[int, ...]]]:
"""
Get the shape of the observation (useful for the buffers).
:param observation_space:
:return:
"""
if isinstance(observation_space, spaces.Box):
return observation_space.shape
elif isinstance(observation_space, spaces.Discrete):
# Observation is an int
return (1,)
elif isinstance(observation_space, spaces.MultiDiscrete):
# Number of discrete features
return (int(len(observation_space.nvec)),)
elif isinstance(observation_space, spaces.MultiBinary):
# Number of binary features
return observation_space.shape
elif isinstance(observation_space, spaces.Dict):
return {key: get_obs_shape(subspace) for (key, subspace) in observation_space.spaces.items()} # type: ignore[misc]
else:
raise NotImplementedError(f"{observation_space} observation space is not supported")
我试着打印
observation_space
形状,这就是我得到的-
Box([-1. -1. -8.], [1. 1. 8.], (3,), float32)
。你知道SB3为什么不接受我的观察形状吗?