我在终端中遇到以下错误:
Traceback (most recent call last):
File "deep_Q_learner.py", line 289, in <module>
agent.replay_experience()
File "deep_Q_learner.py", line 170, in replay_experience
self.learn_from_batch_experience(experience_batch)
File "deep_Q_learner.py", line 151, in learn_from_batch_experience
self.Q_target(next_obs_batch).max(1)[0].data
TypeError: mul(): argument 'other' (position 1) must be Tensor, not numpy.ndarray
仅当self.DQN = SLP时才看到错误(请参阅第76行)
是否已解决此问题?我在这里想念东西吗?
答案 0 :(得分:0)
如错误所示,您应该传递一个torch.tensor对象,其中传递一个numpy数组对象。通过以下方式将您的numpy数组转换为torch.tenosr:
new_torch_tensor = torch.tensor(numpy_array)