强化学习 IndexError:索引28超出了轴1的大小4

问题描述

我正在尝试使用下面的当前代码解决强化学习问题。我在下面发布的代码中遇到了错误

target_q[batch_index,actions] = rewards + self.gamma * np.max(next_q,axis=1)*dones

变量的值和形状如下

target_q值为

[[-0.10855542 -0.0802312   0.06993277  0.00552639]

[-0.09975365 -0.07372604 0.06426253 0.00507834] [-0.12322513 -0.09107337 0.07938312 0.00627324] [-0.08215004 -0.06071554 0.05292208 0.00418217] [-0.10268757 -0.07589445 0.06615258 0.00522767] [-0.11735719 -0.08673649 0.07560297 0.00597452] [-0.10855542 -0.0802312 0.06993277 0.00552639] [-0.07628225 -0.05637873 0.04914192 0.00388342] [0. 0. 0. 0.] [-0.0792161 -0.05854715 0.05103201 0.00403276]]的形状为(10,4)

batch_index = np.arange(self.batch_size,dtype=np.int32),with batch size = 10. 

作用的值为[28 35 45 26 40 33 40 49 34 41],形状为(10,)

奖励的价值为[10. -20。 -20。 -20。 -20。 10. -20。 -20。 -20。 -20。],形状为(10,)

伽玛值为0.99

next_q的值为[[-0.08215004 -0.06071554 0.05292208 0.00418217] [-0.10855542 -0.0802312 0.06993277 0.00552639] [-0.10855542 -0.0802312 0.06993277 0.00552639] [-0.12615901 -0.09324171 0.08127321 0.00642257] [-0.09975365 -0.07372604 0.06426253 0.00507834] [-0.0792161 -0.05854715 0.05103201 0.00403276] [-0.11735719 -0.08673649 0.07560297 0.00597452] [-0.12322513 -0.09107337 0.07938312 0.00627324] [-0.07628225 -0.05637873 0.04914192 0.00388342] [-0.10268757 -0.07589445 0.06615258 0.00522767]],wiit形状(10,4)

dons的值为[1 1 1 1 1 1 1 1 1 1 1],形状为(10,)。

我遇到以下错误

 IndexError: index 28 is out of bounds for axis 1 with size 4. 

有人可以告诉我如何解决错误吗?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)