O。
使用 pyBrain 的强化学习,我们正在尝试解决一个游戏。我们使用 NFQ 和 ActionValueNetwork 作为控制器。我们有我们的自制任务,并且正在使用 pyBrain 的实验设置进行训练。我们的代理在每一集后都会重置。
我们看一集的方式是在一个级别上运行。每一集我们都调用experiment.doInteractions() 直到关卡返回失败或完成。之后我们执行 agent.learn() 和 agent.reset()
起初我们认为这个错误是由于运行一集太长而导致内存溢出。当我们第一次遇到错误时,我们插入的移动最大值为 10.000。我现在将它降低到 50,这使得程序可以运行更多集,但仍然出现错误。
这使我们相信问题不是移动的数量,而是累积的历史被保存在某个地方并过度增长其允许的内存大小。我们相信 agent.reset() 会从内存中清除所有历史记录,不是吗?我们可以阻止历史被保存在某个地方吗?
或者有人有其他建议吗?
编辑:这是异常跟踪。
Running level: Single box block. Try: 125
Traceback (most recent call last):
File "wrapperSokoban.py", line 168, in <module>
wrapperSokoban().run_Qlearning()
File "wrapperSokoban.py", line 154, in run_Qlearning
self.run_Qlearning_level()
File "wrapperSokoban.py", line 122, in run_Qlearning_level
self.experiment.doInteractions()
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/rl/experiments/experiment.py", line 18, in doInteractions
self._oneInteraction()
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/rl/experiments/experiment.py", line 29, in _oneInteraction
self.agent.giveReward(reward)
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/rl/agents/logging.py", line 62, in giveReward
self.history.addSample(self.lastobs, self.lastaction, self.lastreward)
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/datasets/reinforcement.py", line 40, in addSample
self.appendLinked(state, action, reward)
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/datasets/dataset.py", line 216, in appendLinked
self._appendUnlinked(l, args[i])
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/datasets/dataset.py", line 196, in _appendUnlinked
self._resize(label)
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/datasets/dataset.py", line 181, in _resize
self.data[l] = self._resizeArray(self.data[l])
File "/usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/datasets/dataset.py", line 188, in _resizeArray
return resize(a, shape)
File "/usr/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 864, in resize
a = concatenate( (a,)*n_copies)
MemoryError