def print_graph(func): for i, node in enumerate(func.maker.env.toposort()): print i, node # Last node should be the output print i, pprint(node.outputs[0])
import theano import theano.tensor as T x = T.scalar() y = 3*(x**2) + 1 theano.pprint(y) theano.printing.debugprint(y) print y.eval({x: 2}) f = theano.function([x], y) print f(2) X = T.vector() X = T.matrix() X = T.tensor3() X = T.tensor4()
h2 = T.dot(h1, W2.T) # compile and call the actual function f = theano.function([x], h2) f(numpy.random.rand(5, 10)) """ """ import theano.tensor as tt x = tt.vector('x') y = tt.vector('y') s = tt.sum(x**2 + tt.sin(y)) print s theano.pprint(s) #theano.ProfileMode.provided_optimizer=fast_compile #None x = T.vector() y = T.vector() z = x + x z = z + y f = theano.function([x, y], z) #theano.pprint(f) #theano.printing.debugprint(f) 可以输出他的参数类型 f(np.ones((2,)), np.ones((3,)))
import theano import theano.tensor as T x = T.scalar() y = 3 * (x**2) + 1 theano.pprint(y) theano.printing.debugprint(y) print y.eval({x: 2}) f = theano.function([x], y) print f(2) X = T.vector() X = T.matrix() X = T.tensor3() X = T.tensor4()
import theano from theano import printing import theano.tensor as T import numpy as np print(T.scalar()) print(T.iscalar()) print(T.fscalar()) print(T.dscalar()) x = T.matrix('x') y = T.matrix('y') z = x + y print(z) print(theano.pprint(z)) print(printing.debugprint(z)) print(theano.pp(z)) print(z.eval({x: [[1, 2], [1, 3]], y: [[1, 0], [3, 4]]})) addition = theano.function([x, y], [z]) print(addition([[1, 2], [1, 3]], [[1, 0], [3, 4]])) print(printing.debugprint(addition)) print(addition(np.ones((2, 2), dtype=theano.config.floatX), np.zeros((2, 2), dtype=theano.config.floatX))) a = T.zeros((2, 3)) print(a.eval()) b = T.identity_like(a) print(b.eval()) c = T.arange(10) print(c.eval()) print(c.ndim) print(c.dtype)
def __repr__(self): return theano.pprint(self.Y)