提交 cd2dad93 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

add unit tests for clip grad

上级 3968c266
...@@ -883,6 +883,25 @@ if __name__ == '__main__': ...@@ -883,6 +883,25 @@ if __name__ == '__main__':
unittest.TextTestRunner().run(suite) unittest.TextTestRunner().run(suite)
""" """
def test_clip_grad():
# test the gradient of clip
def func(x,y,z):
return theano.tensor.clip(x,y,z)
# use an x value less than y, an x value between y and z, and an x value
# greater than z
unittest_tools.verify_grad(func,
[ numpy.asarray([-1.,0.5,2.]), 0., 1.])
def test_clip_grad_int():
# test that integers don't crash clip gradient
x = tensor.iscalar()
y = tensor.iscalar()
z = tensor.iscalar()
c = tensor.clip(x,y,z)
tensor.grad(c, [x, y, z])
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论