提交 b59de491 authored 作者: James Bergstra's avatar James Bergstra

test_log1p - commented out the test of the complex case... broken by constant upcasting

上级 7860e808
...@@ -905,26 +905,35 @@ def test_log1p(): ...@@ -905,26 +905,35 @@ def test_log1p():
f = function([x,y], T.log(fill(y,1)+(x)), mode=m) f = function([x,y], T.log(fill(y,1)+(x)), mode=m)
print f.maker.env.toposort() print f.maker.env.toposort()
# the first three ops are Shape_i, Shape_i, and Dimshuffle # the first three ops are Shape_i, Shape_i, and Dimshuffle
theano.printing.debugprint(f)
assert [node.op for node in f.maker.env.toposort()][3:] \ assert [node.op for node in f.maker.env.toposort()][3:] \
== [T.log1p, alloc] == [T.log1p, alloc]
f = function([x,y], T.log(0+(x) + fill(y,1.0)), mode=m) f = function([x,y], T.log(0+(x) + fill(y,1.0)), mode=m)
theano.printing.debugprint(f)
assert [node.op for node in f.maker.env.toposort()][3:] \ assert [node.op for node in f.maker.env.toposort()][3:] \
== [T.log1p, alloc] == [T.log1p, alloc]
f = function([x,y], T.log(2+(x) - fill(y,1.0)), mode=m) f = function([x,y], T.log(2+(x) - fill(y,1.0)), mode=m)
theano.printing.debugprint(f)
assert [node.op for node in f.maker.env.toposort()][3:] \ assert [node.op for node in f.maker.env.toposort()][3:] \
== [T.log1p, alloc] == [T.log1p, alloc]
f([1e-7, 10], [[0, 0], [0, 0]]) #debugmode will verify values f([1e-7, 10], [[0, 0], [0, 0]]) #debugmode will verify values
# should work for complex if 0:
z = zmatrix() # at one point this worked, but it has been broken since
f = function([z], T.log(1+(z)), mode=m) # the constant up-casting made 1 -> 1.0+0.0j
assert [node.op for node in f.maker.env.toposort()] == [T.log1p] # I was never sure if this optimization should work on complex numbers or not.
z = zmatrix()
# should work for int f = function([z], T.log(1+(z)), mode=m)
z = imatrix() theano.printing.debugprint(f)
f = function([z], T.log(1+(z)), mode=m) assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
if 1:
# should work for int
z = imatrix()
f = function([z], T.log(1+(z)), mode=m)
theano.printing.debugprint(f)
assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
class test_local_subtensor_unary(unittest.TestCase): class test_local_subtensor_unary(unittest.TestCase):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论