21章MADDPG代码问题,存在维度不匹配
Opened this issue · 2 comments
{
"name": "ValueError",
"message": "setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1024, 3) + inhomogeneous part.",
"stack": "---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/corneliusdeng/UESTC/Dive Into RL/MADDPG.ipynb Cell 7 line 2
26 total_step += 1
27 if replay_buffer.size(
28 ) >= minimal_size and total_step % update_interval == 0:
---> 29 sample = replay_buffer.sample(batch_size)
31 def stack_array(x):
32 rearranged = [[sub_x[i] for sub_x in x]
33 for i in range(len(x[0]))]
File ~/UESTC/Dive Into RL/rl_utils.py:17, in ReplayBuffer.sample(self, batch_size)
15 transitions = random.sample(self.buffer, batch_size)
16 state, action, reward, next_state, done = zip(*transitions)
---> 17 return np.array(state), action, reward, np.array(next_state), done
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1024, 3) + inhomogeneous part."
}