0

I've been trying to debug some Theano code, for which I used Keras as a front end. What I've been doing is inserting either:

import pdb
pdb.set_trace()

or

import code
code.interact(local=locals(), banner='==>")

at the point where I want to begin interacting with my code to see what's going on and interactively test solutions. But, when I use pdb to interact with my code, I see this odd behaviour:

--Return--
> /home/me/Projects/keras_expts2/cifar10_cnn_ecoc2a.py(174)<module>()->None
-> pdb.set_trace()
(Pdb) import theano.tensor as T
(Pdb) a=T.fvector()
(Pdb) type(a)
*** NameError: name 'a' is not defined
(Pdb) T
<module 'theano.tensor' from '/home/smgutstein/Downloads/Theano/theano/tensor/__init__.pyc'>
(Pdb) T.fvector
TensorType(float32, vector)

So, pdb knows what T and fvector are, it just won't create a Theano fvector variable.

However, using code, I see this (better) behaviour:

==>
>>> import theano.tensor as T
>>> a = T.fvector()
>>> type(a)
<class 'theano.tensor.var.TensorVariable'>
>>> T.fvector
TensorType(float32, vector)
>>> 

Why is there this difference?

user1245262
  • 6,968
  • 8
  • 50
  • 77

1 Answers1

0

Because a is a pdb command (short for alias), a=T.fvector() gets parsed as you trying to run that command rather than the Python statement.

Alex Hall
  • 34,833
  • 5
  • 57
  • 89