提交 0fe44b63 authored 作者: James Bergstra's avatar James Bergstra

test_conv: additional printing, separate verify_grad for images and kernels

上级 3e6ad053
...@@ -454,17 +454,39 @@ class TestConvOp(unittest.TestCase): ...@@ -454,17 +454,39 @@ class TestConvOp(unittest.TestCase):
kernvals = N.array(N.random.rand(nkern,visdim,kshp[0], kernvals = N.array(N.random.rand(nkern,visdim,kshp[0],
kshp[1]),dtype=kerns.dtype) kshp[1]),dtype=kerns.dtype)
def testf(imgs, kerns): print 'test_ConvOpGrad'
out, outshp = convolve2(kerns, kshp, nkern, print 'mode type:', mode, typ
print 'imshp:', imshp
print 'kshp:', kshp
print 'un_b:', un_b
print 'un_k:', un_k
print 'ss:', ss
print 'bsize:', bsize
print 'nkern:', 4
def test_i(imgs):
out, outshp = convolve2(kernvals, kshp, nkern,
imgs, imshp, bsize, imgs, imshp, bsize,
mode=mode, step=ss, mode=mode, step=ss,
unroll_batch=un_b, unroll_batch=un_b,
unroll_kern=un_k) unroll_kern=un_k)
return out return out
#TODO the tolerance needed to pass is very high for float32(0.16). Is this acceptable? Expected? def test_k(kerns):
utt.verify_grad(testf, [imgvals, kernvals], out, outshp = convolve2(kerns, kshp, nkern,
imgvals, imshp, bsize,
mode=mode, step=ss,
unroll_batch=un_b,
unroll_kern=un_k)
return out
#TODO the tolerance needed to pass is very high for float32(0.17). Is this acceptable? Expected?
utt.verify_grad(test_i, [imgvals],
cast_to_output_type=True,
tol=None if typ!="float32" else 0.17)
utt.verify_grad(test_k, [kernvals],
cast_to_output_type=True, cast_to_output_type=True,
tol=None if typ!="float32" else 0.16) tol=None if typ!="float32" else 0.17)
if __name__ == '__main__': if __name__ == '__main__':
t = TestConvOp("test_convolution") t = TestConvOp("test_convolution")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论