提交 9e91983b authored 作者: nouiz's avatar nouiz

Merge pull request #251 from pascanur/some_fixes_tests_scan

Some fixes tests scan
...@@ -2018,12 +2018,6 @@ class T_Scan(unittest.TestCase): ...@@ -2018,12 +2018,6 @@ class T_Scan(unittest.TestCase):
if theano.config.mode != 'FAST_COMPILE': if theano.config.mode != 'FAST_COMPILE':
self.assertTrue(nb_shape_i == 1) self.assertTrue(nb_shape_i == 1)
def test_bug_josh_reported(self):
import theano.tensor.signal.conv
m1 = theano.tensor.matrix()
m2 = theano.tensor.matrix()
conv = theano.tensor.signal.conv.conv2d(m1, m2)
def test_merge(self): def test_merge(self):
x = theano.tensor.vector() x = theano.tensor.vector()
y = theano.tensor.vector() y = theano.tensor.vector()
...@@ -2525,6 +2519,44 @@ class T_Scan(unittest.TestCase): ...@@ -2525,6 +2519,44 @@ class T_Scan(unittest.TestCase):
out = f(vx) out = f(vx)
assert out == 24 assert out == 24
def test_infershape_seq_shorter_nsteps(self):
raise KnownFailureTest('This is a generic problem with infershape'
' that has to be discussed and figured out')
x = tensor.vector('x')
[o1, o2], _ = theano.scan(lambda x,y: (x+1, y+x),
sequences = x,
outputs_info = [None, x[0]],
n_steps = 20)
f = theano.function([x], [o1.shape[0], o2.shape[0]], mode = mode_with_opt)
vx = numpy.ones((10,), dtype = theano.config.floatX)
out1, out2 = f(vx)
assert out1 == 10
assert out2 == 10
lssc = [x for x in f.maker.env.toposort()
if isinstance(x.op, theano.scan_module.scan_op.Scan)]
assert len(lssc) == 0
def test_infershape_nsteps_smaller_seq_length(self):
x = tensor.vector('x')
[o1, o2], _ = theano.scan(lambda x, y: (x+1, y+x),
sequences = x,
outputs_info = [None, x[0]],
n_steps = 20)
f = theano.function([x], [o1.shape[0], o2.shape[0]],
mode = mode_with_opt)
vx = numpy.ones((30,), dtype = theano.config.floatX)
o1, o2 = f(vx)
assert o1 == 20
assert o2 == 20
lssc = [x for x in f.maker.env.toposort()
if isinstance(x.op, theano.scan_module.scan_op.Scan)]
assert len(lssc) == 0
def test_grad_multiple_seqs_different_nsteps(self): def test_grad_multiple_seqs_different_nsteps(self):
# Example provided Michael Forbes # Example provided Michael Forbes
# This test assures that we clip the sequences to n_steps before # This test assures that we clip the sequences to n_steps before
......
...@@ -97,3 +97,14 @@ class TestSignalConv2D(unittest.TestCase): ...@@ -97,3 +97,14 @@ class TestSignalConv2D(unittest.TestCase):
self.fail() self.fail()
except: except:
pass pass
def test_bug_josh_reported(self):
"""
Test refers to a bug reported by Josh, when due to a bad merge these
few lines of code failed. See
http://groups.google.com/group/theano-dev/browse_thread/thread/8856e7ca5035eecb
"""
m1 = theano.tensor.matrix()
m2 = theano.tensor.matrix()
rval = conv.conv2d(m1, m2)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论