agi-brain/xuance

当所有env都done时会报错

Opened this issue · 1 comments

老师好,首先向您的工作致以敬意!
当所有env都done时,会运行到这句代码:位于xuance/torch/runners/runner_pettingzoo.py文件的第219-220行,

if done_n[h][i_env].all():
    mas_group.memory.finish_path(0.0, i_env)

这个被置为0.0的值会引发位于xuance/common/memory_tools_marl.py文件中,finish_path()函数中该语句的报错:

vs = np.append(np.array(self.data['values'][i_env, path_slice]), [value], axis=0)

报错内容为:ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 3 dimension(s) and the array at index 1 has 1 dimension(s)
为了解决这个维数不匹配的问题,需要在vs = np.append(...)语句之前添加:

if value == 0.0:
    value = [[0.0]]

如此即可解决这个问题。

Thank you very much for your valuable suggestions. We will enhance the code by carefully addressing the issues you raised.