【发布时间】:2020-07-25 10:37:07
【问题描述】:
我编写了一个代码来解决 Atari Breakout。我面临一个小问题,但我不能说它是什么。
这里是code
这是回放内存的问题。
try:
next_states = torch.tensor(batch[3], dtype=torch.float32)
except:
import ipdb; ipdb.set_trace()
问题出在这些行在哪里。 set_trace() 用于弹出交互式 shell。从那里,如果我运行for i in range(batch_size): print(batch[3][i].shape),我会得到这个输出
ipdb> for i in range(32): print(batch[3][i].shape)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
(4, 84, 84)
*** AttributeError: 'NoneType' object has no attribute 'shape'
如何改进该代码以避免此类错误?
【问题讨论】:
-
这个问题更适合Stack Overflow(因为这只是一个编程问题)。我会将它迁移到 SO 并在那里提供正式的答案。
标签: python-3.x reinforcement-learning dqn