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

Add outer grad tests with broadcastable dimensions.

上级 3c02fd50
......@@ -2739,10 +2739,31 @@ class T_outer(unittest.TestCase):
s2 = numpy.random.randint(1, 10, n)
v1 = numpy.asarray(numpy.random.rand(*s1)).astype(floatX)
v2 = numpy.asarray(numpy.random.rand(*s2)).astype(floatX)
print m, n, s1, s2
o = tensor.outer(x, y).eval({x: v1, y: v2})
assert_allclose(o, numpy.outer(v1, v2))
def test_grad(self):
"""
Test the combined graph of the graph of outer
with broadcastable dimensions, just in case.
"""
for shp0, shp1 in [((1,), (2,)),
((3,), (1,)),
((1,), (1,)),
((3,), (2,)),
((3, 2), (1, 1)),
((3, 2), (1, 4)),
((3, 2), (4, 1)),
((3, 2), (4, 5)),
((1, 2), (4, 5)),
((3, 1), (4, 5)),
((1, 1), (4, 5)),
((1, 1), (1, 1)),
]:
data0 = numpy.random.rand(*shp0).astype(floatX)
data1 = numpy.random.rand(*shp1).astype(floatX)
utt.verify_grad(tensor.outer, [data0, data1])
class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
"""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论