【发布时间】:2021-03-31 17:18:15
【问题描述】:
我正在尝试用这个观察空间运行一个 q-learning 算法:
self.observation_space = spaces.Box(low=np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), high=np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), dtype=np.flo
当我试图访问 q 表时,像这样:
q_value = q_table[state][action]
我收到此错误:
IndexError: arrays used as indices must be of integer (or boolean) type
所以我的问题是:当我的观察空间使用 space.box 定义时,我应该如何访问 q 表?
如果需要,这就是 q_table 的定义方式(它是我从互联网上获取的代码,试图将其调整为我的项目):
num_box = tuple((env.observation_space.high + np.ones(env.observation_space.shape)).astype(int))
q_table = np.zeros(num_box + (env.action_space.n,))
【问题讨论】:
标签: python openai-gym q-learning