提交 353755c6 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

fixed a test that wanted gradient to flow through integers

now it is two tests, one with an integer, asserting grad is 0 one with a float, asserting grad is what it was before
上级 d0681eb8
......@@ -4328,7 +4328,24 @@ class T_tensorfromscalar(unittest.TestCase):
self.assertTrue(v.shape == (), v.shape)
g = grad(t, s)
self.assertTrue(eval_outputs([g])==1)
self.assertTrue(eval_outputs([g])==0.)
def test2(self):
s = scal.constant(56.)
t = as_tensor_variable(s)
self.assertTrue(t.owner.op is tensor_from_scalar)
self.assertTrue(t.type.broadcastable == (), t.type.broadcastable)
self.assertTrue(t.type.ndim == 0, t.type.ndim)
self.assertTrue(t.type.dtype == s.type.dtype)
v = eval_outputs([t])
self.assertTrue(v == 56., v)
self.assertTrue(isinstance(v, numpy.ndarray))
self.assertTrue(v.shape == (), v.shape)
g = grad(t, s)
self.assertTrue(eval_outputs([g])==1.)
class T_scalarfromtensor(unittest.TestCase):
def test0(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论