Skip to content

Instantly share code, notes, and snippets.

@rizar
Created November 14, 2014 16:41
Show Gist options
  • Save rizar/ea6aa6e750e1a9548703 to your computer and use it in GitHub Desktop.
Save rizar/ea6aa6e750e1a9548703 to your computer and use it in GitHub Desktop.
import numpy
import theano
from theano import tensor
from theano.printing import debugprint
floatX = theano.config.floatX
foo_a, foo_x, r = 3 * [None]
def foo(x, a):
global foo_a, foo_x, r
foo_a = a
foo_x = x
r = a + x
return r
x = tensor.vector('x')
s, _ = theano.scan(foo, sequences=x,
outputs_info=[numpy.array(0, dtype=floatX)])
r2 = foo_x - foo_a
# Prints two similar scan inner graphs
debugprint(s)
debugprint(theano.clone(s, replace=[(r, r2)]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment