提交 f9aec00b authored 作者: Mohammad Pezeshki's avatar Mohammad Pezeshki

local variable 'profile' added with a default value of None

上级 44100a3f
import numpy
import theano
import theano.tensor as T
from theano.printing import debugprint
X = T.matrix('X')
W = T.matrix('W')
Y = T.dot(X, W)
R = X - W
Z = Y + R
f = theano.function(inputs=[X, W], outputs=[Z, R], profile=True)
for i in xrange(10):
f(numpy.random.uniform(size=(2, 2)),
numpy.random.uniform(size=(2, 2)))
#print f.profile.compute_total_times()
#print f.profile.apply_time
debugprint(f)
......@@ -73,6 +73,7 @@ def debugprint(obj, depth=-1, print_type=False,
to the Apply's identifier, to indicate which output a line corresponds to.
"""
profile = None
if file == 'str':
_file = StringIO()
elif file is None:
......@@ -94,7 +95,7 @@ def debugprint(obj, depth=-1, print_type=False,
elif isinstance(obj, Function):
results_to_print.extend(obj.maker.fgraph.outputs)
order = obj.maker.fgraph.toposort()
profile=obj.profile
profile = obj.profile
if profile != None:
print 'Timing Info\n-----------\n\t \
--> <time> <% time> - <total time> <% total time>'
......@@ -118,7 +119,8 @@ def debugprint(obj, depth=-1, print_type=False,
debugmode.debugprint(r, depth=depth, done=done, print_type=print_type,
file=_file, order=order, ids=ids,
scan_ops=scan_ops, stop_on_name=stop_on_name)
scan_ops=scan_ops, stop_on_name=stop_on_name,
profile=profile)
if len(scan_ops) > 0:
print >> file, ""
new_prefix = ' >'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论