提交 90cf38f3 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Added test to make sure a zero gradient still preserves the shape

上级 cfaf9c94
......@@ -1686,6 +1686,14 @@ class test_grad(unittest.TestCase):
self.failUnless(g2.owner.op == fill)
self.failUnless(g2.owner.inputs[1].data == 0)
def test_zero_gradient_shape(self):
"""Ensure that a zero gradient has the proper shape."""
x = dmatrix()
f = theano.function([x], grad(dscalar(), x))
a = numpy.ones((3, 7))
self.failUnless((f(a) == 0).all()) # Zero gradient.
self.failUnless(a.shape == f(a).shape) # With proper shape.
class T_op_cache(unittest.TestCase):
def setUp(self):
utt.seed_rng()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论