提交 ee668ce2 authored 作者: Frederic's avatar Frederic

pep8, duplicate var name fix.

上级 7aa4c77b
...@@ -2511,7 +2511,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2511,7 +2511,7 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.set_subtensor(x0[:4], y0) z = tensor.set_subtensor(x0[:4], y0)
f = theano.function([x, y], z, mode=self.mode) f = theano.function([x, y], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.IncSubtensor) for x in assert numpy.all([not isinstance(n.op, tensor.IncSubtensor) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
def test_setsubtensor_allocs1(self): def test_setsubtensor_allocs1(self):
...@@ -2521,7 +2521,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2521,7 +2521,7 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.set_subtensor(x0[:4], y0) z = tensor.set_subtensor(x0[:4], y0)
f = theano.function([y], z, mode=self.mode) f = theano.function([y], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.IncSubtensor) for x in assert numpy.all([not isinstance(n.op, tensor.IncSubtensor) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
def test_setsubtensor_allocs1t(self): def test_setsubtensor_allocs1t(self):
...@@ -2531,7 +2531,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2531,7 +2531,7 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.set_subtensor(x0[:4], y0.T) z = tensor.set_subtensor(x0[:4], y0.T)
f = theano.function([y], z, mode=mode_opt) f = theano.function([y], z, mode=mode_opt)
assert numpy.all([not isinstance(x.op, tensor.IncSubtensor) for x in assert numpy.all([not isinstance(n.op, tensor.IncSubtensor) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
def test_setsubtensor_allocs2(self): def test_setsubtensor_allocs2(self):
...@@ -2550,7 +2550,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2550,7 +2550,7 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[:4], y0) z = tensor.inc_subtensor(x[:4], y0)
f = theano.function([x, y], z, mode=self.mode) f = theano.function([x, y], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.IncSubtensor) for x in assert numpy.all([not isinstance(n.op, tensor.IncSubtensor) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
def test_incsubtensor_allocs0t(self): def test_incsubtensor_allocs0t(self):
...@@ -2559,7 +2559,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2559,7 +2559,7 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[:4], y0.T) z = tensor.inc_subtensor(x[:4], y0.T)
f = theano.function([x, y], z, mode=mode_opt) f = theano.function([x, y], z, mode=mode_opt)
assert numpy.all([not isinstance(x.op, tensor.IncSubtensor) for x in assert numpy.all([not isinstance(n.op, tensor.IncSubtensor) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
def test_incsubtensor_allocs1(self): def test_incsubtensor_allocs1(self):
...@@ -2577,8 +2577,8 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2577,8 +2577,8 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0) z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0)
f = theano.function([x, y], z, mode=self.mode) f = theano.function([x, y], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor1) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor1)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_advancedincsubtensor1_allocs0t(self): def test_advancedincsubtensor1_allocs0t(self):
x = tensor.matrix() x = tensor.matrix()
...@@ -2586,8 +2586,8 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2586,8 +2586,8 @@ class Test_alloc_zero(unittest.TestCase):
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0.T) z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0.T)
f = theano.function([x, y], z, mode=mode_opt) f = theano.function([x, y], z, mode=mode_opt)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor1) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor1)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_advancedincsubtensor1_allocs1(self): def test_advancedincsubtensor1_allocs1(self):
x = tensor.matrix() x = tensor.matrix()
...@@ -2595,44 +2595,44 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2595,44 +2595,44 @@ class Test_alloc_zero(unittest.TestCase):
dtype=config.floatX)) dtype=config.floatX))
z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0) z = tensor.inc_subtensor(x[[0, 1, 2, 3]], y0)
f = theano.function([x], z, mode=self.mode) f = theano.function([x], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor1) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor1)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_advancedincsubtensor_allocs0(self): def test_advancedincsubtensor_allocs0(self):
if tensor.inplace_increment is None: if tensor.inplace_increment is None:
raise SkipTest('NumPy version >= 1.8 not available') raise SkipTest('NumPy version >= 1.8 not available')
x = tensor.matrix() x = tensor.matrix()
y = tensor.matrix() y = tensor.matrix()
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0) z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0)
f = theano.function([x, y], z, mode=self.mode) f = theano.function([x, y], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_advancedincsubtensor_allocs0t(self): def test_advancedincsubtensor_allocs0t(self):
if tensor.inplace_increment is None: if tensor.inplace_increment is None:
raise SkipTest('NumPy version >= 1.8 not available') raise SkipTest('NumPy version >= 1.8 not available')
x = tensor.matrix() x = tensor.matrix()
y = tensor.matrix() y = tensor.matrix()
y0 = tensor.zeros_like(y) y0 = tensor.zeros_like(y)
z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0.T) z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0.T)
f = theano.function([x, y], z, mode=mode_opt) f = theano.function([x, y], z, mode=mode_opt)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_advancedincsubtensor_allocs1(self): def test_advancedincsubtensor_allocs1(self):
if tensor.inplace_increment is None: if tensor.inplace_increment is None:
raise SkipTest('NumPy version >= 1.8 not available') raise SkipTest('NumPy version >= 1.8 not available')
x = tensor.matrix() x = tensor.matrix()
y0 = tensor.constant(numpy.asarray(numpy.zeros_like((2, 2)), y0 = tensor.constant(numpy.asarray(numpy.zeros_like((2, 2)),
dtype=config.floatX)) dtype=config.floatX))
z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0) z = tensor.inc_subtensor(x[[[0, 0], [1, 1]], [[0, 1], [0, 1]]], y0)
f = theano.function([x], z, mode=self.mode) f = theano.function([x], z, mode=self.mode)
assert numpy.all([not isinstance(x.op, tensor.AdvancedIncSubtensor) assert numpy.all([not isinstance(n.op, tensor.AdvancedIncSubtensor)
for x in f.maker.fgraph.toposort()]) for n in f.maker.fgraph.toposort()])
def test_dot_allocs_0(self): def test_dot_allocs_0(self):
v1 = tensor.vector('v1') v1 = tensor.vector('v1')
...@@ -2658,7 +2658,7 @@ class Test_alloc_zero(unittest.TestCase): ...@@ -2658,7 +2658,7 @@ class Test_alloc_zero(unittest.TestCase):
f = theano.function([_e1[0], _e2[0]], o, mode=self.mode) f = theano.function([_e1[0], _e2[0]], o, mode=self.mode)
f(_e1[1], _e2[1]) f(_e1[1], _e2[1])
f(_e1[2], _e2[2]) f(_e1[2], _e2[2])
assert numpy.all([not isinstance(x.op, tensor.Dot) for x in assert numpy.all([not isinstance(n.op, tensor.Dot) for n in
f.maker.fgraph.toposort()]) f.maker.fgraph.toposort()])
#test that we don't remove shape errors #test that we don't remove shape errors
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论