提交 53d7894d authored 作者: David Warde-Farley's avatar David Warde-Farley

Simplify and improve roll tests.

上级 5b5d1d9f
......@@ -2823,31 +2823,37 @@ class T_Join_and_Split(unittest.TestCase):
assert (out == want).all()
# Test simple 1D example with explicit 0 axis
b = roll(a, -1, 0)
want = numpy.array([2, 3, 4, 5, 6, 1])
out = theano.function([], b)()
assert (out == want).all()
# Test 2D example - ensure that behavior matches numpy.roll behavior
a = self.shared(numpy.arange(21).reshape((3, 7)))
b = roll(a, -2, 1)
want = numpy.arange(21).reshape((3, 7))
want = numpy.roll(want, -2, 1)
want = numpy.roll(a.get_value(borrow=True), -2, 1)
out = theano.function([], b)()
assert (out == want).all()
# Test rolling on axis 0
want = numpy.arange(21).reshape((3, 7))
want = numpy.roll(want, -2, 0)
want = numpy.roll(a.get_value(borrow=True), -2, 0)
b = roll(a, -2, 0)
out = theano.function([], b)()
assert (out == want).all()
# Test rolling on default axis with ndim > 1
want = numpy.roll(numpy.arange(21).reshape((3, 7)), 2)
want = numpy.roll(a.get_value(borrow=True), 2)
b = roll(a, 2)
out = theano.function([], b)()
assert (out == want).all()
def test_stack_vector(self):
a = self.shared(numpy.array([1, 2, 3], dtype=self.floatX))
b = as_tensor_variable(numpy.array([7, 8, 9], dtype=self.floatX))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论