提交 63c4209a authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use debugprint instead of helper function.

上级 c880fff7
...@@ -326,13 +326,6 @@ class T_CrossentropyCategorical1HotGrad(utt.InferShapeTester): ...@@ -326,13 +326,6 @@ class T_CrossentropyCategorical1HotGrad(utt.InferShapeTester):
class T_CrossentropyCategorical1Hot(utt.InferShapeTester): class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
def print_graph(self, func):
# Helper function used in different tests
for i, node in enumerate(func.maker.fgraph.toposort()):
print i, node
# Last node should be the output
print i, printing.pprint(node.outputs[0])
print
def test_grad(self): def test_grad(self):
x = tensor.matrix('x') x = tensor.matrix('x')
...@@ -794,7 +787,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -794,7 +787,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
for expr in bias_expressions: for expr in bias_expressions:
f = theano.function([x, y], expr, mode=mode) f = theano.function([x, y], expr, mode=mode)
if verbose: if verbose:
self.print_graph(f) printing.debugprint(f)
try: try:
ops = [node.op for node in f.maker.fgraph.toposort()] ops = [node.op for node in f.maker.fgraph.toposort()]
assert len(ops) == 5 assert len(ops) == 5
...@@ -807,7 +800,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -807,7 +800,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
raise raise
g = theano.function([x, y], T.grad(expr, x), mode=mode) g = theano.function([x, y], T.grad(expr, x), mode=mode)
if verbose: if verbose:
self.print_graph(g) printing.debugprint(g)
try: try:
ops = [node.op for node in g.maker.fgraph.toposort()] ops = [node.op for node in g.maker.fgraph.toposort()]
assert len(ops) == 4 assert len(ops) == 4
...@@ -843,7 +836,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -843,7 +836,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
for expr in bias_expressions: for expr in bias_expressions:
f = theano.function([x, b, y], expr, mode=mode) f = theano.function([x, b, y], expr, mode=mode)
if verbose: if verbose:
self.print_graph(f) printing.debugprint(f)
try: try:
ops = [node.op for node in f.maker.fgraph.toposort()] ops = [node.op for node in f.maker.fgraph.toposort()]
# [big_op, sum, dim_shuffle] # [big_op, sum, dim_shuffle]
...@@ -864,7 +857,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -864,7 +857,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
config.warn.sum_div_dimshuffle_bug = backup config.warn.sum_div_dimshuffle_bug = backup
if verbose: if verbose:
self.print_graph(g) printing.debugprint(g)
try: try:
ops = [node.op for node in g.maker.fgraph.toposort()] ops = [node.op for node in g.maker.fgraph.toposort()]
assert len(ops) <= 6 assert len(ops) <= 6
...@@ -904,7 +897,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -904,7 +897,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
for expr in bias_expressions: for expr in bias_expressions:
f = theano.function([x, b, y_], expr, mode=mode) f = theano.function([x, b, y_], expr, mode=mode)
if verbose: if verbose:
self.print_graph(f) printing.debugprint(f)
try: try:
ops = [node.op for node in f.maker.fgraph.toposort()] ops = [node.op for node in f.maker.fgraph.toposort()]
# [big_op, sum, dim_shuffle, flatten] # [big_op, sum, dim_shuffle, flatten]
...@@ -925,7 +918,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -925,7 +918,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
config.warn.sum_div_dimshuffle_bug = backup config.warn.sum_div_dimshuffle_bug = backup
if verbose: if verbose:
self.print_graph(g) printing.debugprint(g)
try: try:
ops = [node.op for node in g.maker.fgraph.toposort()] ops = [node.op for node in g.maker.fgraph.toposort()]
assert len(ops) <= 6 assert len(ops) <= 6
...@@ -966,7 +959,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -966,7 +959,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
for expr in bias_expressions: for expr in bias_expressions:
f = theano.function([x, b, y_], expr, mode=mode) f = theano.function([x, b, y_], expr, mode=mode)
if verbose: if verbose:
self.print_graph(f) printing.debugprint(f)
try: try:
ops = [node.op for node in f.maker.fgraph.toposort()] ops = [node.op for node in f.maker.fgraph.toposort()]
# [big_op, sum, dim_shuffle, specify_shape] # [big_op, sum, dim_shuffle, specify_shape]
...@@ -987,7 +980,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester): ...@@ -987,7 +980,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
config.warn.sum_div_dimshuffle_bug = backup config.warn.sum_div_dimshuffle_bug = backup
if verbose: if verbose:
self.print_graph(g) printing.debugprint(g)
try: try:
ops = [node.op for node in g.maker.fgraph.toposort()] ops = [node.op for node in g.maker.fgraph.toposort()]
assert len(ops) <= 6 assert len(ops) <= 6
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论