TypeError: only integer scalar arrays can be converted to a scalar index
问题描述:
在经验池中的 state 从之前的单个array,重新设计为 三个array 组合成为的一个list
所以list在面对随意采样索引出现报错:
TypeError: only integer scalar arrays can be converted to a scalar index
问题解决:
将list 转换为 array就行
错误代码为
max_buffer = min(self.counter, self.size)
batch = np.random.choice(max_buffer, batch_size, replace=False)
state_batch = self.state_buffer[batch]
修改:
max_buffer = min(self.counter, self.size)
batch = np.random.choice(max_buffer, batch_size, replace=False)
state_batch = np.array(self.state_buffer)[batch]