提交 438e7b2b authored 作者: AdeB's avatar AdeB 提交者: Pascal Lamblin

Fix other check trace problems

上级 98c241c8
...@@ -76,7 +76,10 @@ def pyconv3d(signals, filters): ...@@ -76,7 +76,10 @@ def pyconv3d(signals, filters):
def check_diagonal_subtensor_view_traces(fn): def check_diagonal_subtensor_view_traces(fn):
assert check_stack_trace(fn, [DiagonalSubtensor, IncDiagonalSubtensor]) def check_node_type(node):
return isinstance(node.op, (DiagonalSubtensor, IncDiagonalSubtensor))
assert check_stack_trace(fn, ops_to_check=check_node_type,
bug_print='ignore')
def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared): def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
......
...@@ -306,7 +306,6 @@ class T_sigmoid_opts(unittest.TestCase): ...@@ -306,7 +306,6 @@ class T_sigmoid_opts(unittest.TestCase):
mode = self.get_mode() mode = self.get_mode()
if not isinstance(mode, theano.compile.DebugMode): if not isinstance(mode, theano.compile.DebugMode):
f = theano.function([x, lr], ux, mode=mode) f = theano.function([x, lr], ux, mode=mode)
assert hasattr(f.maker.fgraph.outputs[0].tag, 'trace')
ux_v = f([[50]], 0.1) ux_v = f([[50]], 0.1)
assert not numpy.isnan(ux_v) assert not numpy.isnan(ux_v)
...@@ -365,13 +364,16 @@ class T_softplus_opts(unittest.TestCase): ...@@ -365,13 +364,16 @@ class T_softplus_opts(unittest.TestCase):
out = T.log(sigmoid(x)) out = T.log(sigmoid(x))
f = theano.function([x], out, mode=self.m) f = theano.function([x], out, mode=self.m)
ops_to_check = [theano.scalar.Neg, types_to_check = (theano.scalar.Neg,
theano.tensor.nnet.sigm.ScalarSoftplus, theano.tensor.nnet.sigm.ScalarSoftplus,
theano.scalar.Neg] theano.scalar.Neg)
assert check_stack_trace(f, ops_to_check=ops_to_check)
assert check_stack_trace(
f, ops_to_check=
lambda x: isinstance(x.op.scalar_op, types_to_check))
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
assert len(topo) == 3 assert len(topo) == 3
for i, op in enumerate(ops_to_check): for i, op in enumerate(types_to_check):
assert isinstance(topo[i].op.scalar_op, op) assert isinstance(topo[i].op.scalar_op, op)
f(numpy.random.rand(54).astype(config.floatX)) f(numpy.random.rand(54).astype(config.floatX))
...@@ -390,9 +392,8 @@ class T_softplus_opts(unittest.TestCase): ...@@ -390,9 +392,8 @@ class T_softplus_opts(unittest.TestCase):
# Same test with a flatten # Same test with a flatten
out = T.log(1 - T.flatten(sigmoid(x))) out = T.log(1 - T.flatten(sigmoid(x)))
f = theano.function([x], out, mode=self.m) f = theano.function([x], out, mode=self.m)
assert check_stack_trace(
f, ops_to_check=[theano.tensor.nnet.sigm.ScalarSoftplus, assert check_stack_trace(f, ops_to_check='all')
theano.scalar.Neg])
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
assert len(topo) == 3 assert len(topo) == 3
assert tensor.is_flat(topo[0].outputs[0]) assert tensor.is_flat(topo[0].outputs[0])
...@@ -421,8 +422,8 @@ class T_softplus_opts(unittest.TestCase): ...@@ -421,8 +422,8 @@ class T_softplus_opts(unittest.TestCase):
out = T.log(1 + T.exp(x)) out = T.log(1 + T.exp(x))
f = theano.function([x], out, mode=self.m) f = theano.function([x], out, mode=self.m)
assert check_stack_trace(
f, ops_to_check=theano.tensor.nnet.sigm.ScalarSoftplus) assert check_stack_trace(f, ops_to_check='all')
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
assert len(topo) == 1 assert len(topo) == 1
assert isinstance(topo[0].op.scalar_op, assert isinstance(topo[0].op.scalar_op,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论