Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POMDP Maze cannot be run in Pybrain #239

Open
semolnahali opened this issue Jun 5, 2018 · 0 comments
Open

POMDP Maze cannot be run in Pybrain #239

semolnahali opened this issue Jun 5, 2018 · 0 comments

Comments

@semolnahali
Copy link

semolnahali commented Jun 5, 2018

The following code is rl.py that implements mdp maze in pybrain:

from scipy import * #@UnusedWildImport
import matplotlib.pyplot as plt
from pybrain.rl.environments.mazes import Maze, MDPMazeTask
from pybrain.rl.learners.valuebased import ActionValueTable
from pybrain.rl.agents import LearningAgent
from pybrain.rl.learners import Q, SARSA #@UnusedImport
from pybrain.rl.experiments import Experiment

plt.gray()
plt.ion()
structure = array([[1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 1, 0, 0, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 1, 0, 1],
[1, 0, 0, 1, 0, 0, 0, 0, 1],
[1, 0, 0, 1, 0, 1, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1]])
environment = Maze(structure, (7, 7))
controller = ActionValueTable(81, 4)
learner = Q()
agent = LearningAgent(controller, learner)
task = MDPMazeTask(environment)
experiment = Experiment(task, agent)
while True:
experiment.doInteractions(100)
agent.learn()
agent.reset()
plt.pcolor(controller.params.reshape(81,4).max(1).reshape(9,9))
plt.show()
plt.pause(0.1)

I tried to change it to pomdp maze by replacing 'task = MDPMazeTask(environment)' with 'task = TrivialMaze()
'

but this encountered the following errors :
Traceback (most recent call last):
File "/home/web/pybrain-master/docs/tutorials/rl.py", line 140, in
experiment.doInteractions(100)# speed of learning
File "/home/web/pybrain-master/pybrain/rl/experiments/experiment.py", line 18, in doInteractions
self._oneInteraction()
File "/home/web/pybrain-master/pybrain/rl/experiments/experiment.py", line 27, in _oneInteraction
self.task.performAction(self.agent.getAction())
File "/home/web/pybrain-master/pybrain/rl/agents/learning.py", line 50, in getAction
self.lastaction = self.module.activate(self.lastobs)
File "/home/web/pybrain-master/pybrain/structure/modules/module.py", line 121, in activate
assert len(self.inputbuffer[self.offset]) == len(inpt), str((len(self.inputbuffer[self.offset]), len(inpt)))
AssertionError: (1, 4)

Can anyone help me please?

@semolnahali semolnahali changed the title POMDP Maze cannot be run POMDP Maze cannot be run in Pybrain Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant