【发布时间】:2023-01-31 02:56:24
【问题描述】:
我是强化学习的初学者,所以不要苛刻地评判我。
错误:AssertionError:reset()方法返回的观察与给定的观察空间不匹配
观察空间:
self.observation_space = gym.spaces.Tuple((
gym.spaces.Box(low=-float('inf'), high=self.fp.HEIGHT, shape=(1,), dtype=np.float64), # player y
gym.spaces.Box(low=0, high=self.fp.WIDTH + self.fp.MIN_PIPE_GAP + self.fp.PIPE_WIDTH, shape=(2,), dtype=np.float64), # pipes x
gym.spaces.Box(low=-float('inf'), high=float('inf'), shape=(1,), dtype=np.float64), # gravity
gym.spaces.Box(low=-(self.fp.HEIGHT / 4 * 3 + self.fp.MIN_PIPE_GAP + 100), high=self.fp.HEIGHT / 4 * 3 + self.fp.MIN_PIPE_GAP + 100, shape=(4,), dtype=np.float64), # pipes y
gym.spaces.Box(low=self.fp.PX, high=self.fp.PX, shape=(1,), dtype=np.float64) # player x
))
返回观察:
return (
np.array([float(self.py)]), # py
np.array([float(self.pipes[ind]['x']), float(self.pipes[ind + 1]['x'])]), # x1 x2
np.array([float(self.gravity)]), # gravity
np.array([float(self.pipes[ind]['y1']), float(self.pipes[ind]['y2']), float(self.pipes[ind + 1]['y1']), float(self.pipes[ind + 1]['y2'])]), # y1 y2 y3 y4
np.array([float(self.PX)]) # px
)
我试图将所有内容都放在一个数组中(它起作用了),但这是错误的,因为不同的数据组需要不同的边界。最有可能的是,错误的格式不对,如果根据您的说法,一切都是正确的,那么我会尝试在边框中找到错误
【问题讨论】:
标签: python deep-learning reinforcement-learning openai-gym