ajknzhol
ajknzhol

Reputation: 6450

Pylab Plot Not Showing Up?

I am trying to implement Q Learning but the plot is not showing up anywhere. I am trying it out in PyCharm Windows with Python 2.7.5.

from scipy import *
import pylab

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
from pybrain.rl.experiments import Experiment

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, 1, 0, 1],
                   [1, 0, 0, 1, 0, 1, 1, 0, 1],
                   [1, 0, 0, 0, 0, 0, 1, 0, 1],
                   [1, 1, 1, 1, 1, 1, 1, 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)
controller.initialize(1.)

learner = Q()
agent = LearningAgent(controller, learner)

task = MDPMazeTask(environment)

experiment = Experiment(task, agent)

while True:
    experiment.doInteractions(100)
    agent.learn()
    agent.reset()

    pylab.pcolor(controller.params.reshape(81,4).max(1).reshape(9,9))
    pylab.draw()

Expected Output: The Plot should come.

I have the following installed in my Windows Machine.

PyBrain==0.3
PythonMagick==0.9.9
ipython==1.2.1
libsvm==3.17
matplotlib==1.3.1
numpy==1.8.0
pyparsing==2.0.1
pyreadline==2.0
python-dateutil==2.2
pytz==2013.9
scikit-learn==0.14.1
scipy==0.13.3
six==1.5.2

Current Output: Nothing Displays. Process just ends successfully.

How to get it to work. Help it guys.

Upvotes: 0

Views: 374

Answers (1)

Svend Feldt
Svend Feldt

Reputation: 778

You need to start the gui threat. You do this by either go to interactive mode or use

pylab.show ()

Upvotes: 2

Related Questions