提交 bbcd3418 authored 作者: fsavard's avatar fsavard

Test case for Images2Neibs involving a grad which makes it crash, plus solution (but commented).

上级 3a0282f2
...@@ -233,6 +233,7 @@ def neibs2images(neibs, neib_shape, original_shape): ...@@ -233,6 +233,7 @@ def neibs2images(neibs, neib_shape, original_shape):
new_neib_shape = T.stack( original_shape[-1]/neib_shape[1], neib_shape[1] ) new_neib_shape = T.stack( original_shape[-1]/neib_shape[1], neib_shape[1] )
return images2neibs(neibs.dimshuffle('x','x',0,1), new_neib_shape).reshape(original_shape) return images2neibs(neibs.dimshuffle('x','x',0,1), new_neib_shape).reshape(original_shape)
#return images2neibs(neibs.reshape((1,1,neibs.shape[0],neibs.shape[1])), new_neib_shape).reshape(original_shape)
# This is work in progress # This is work in progress
......
import numpy import numpy
import numpy.random
import theano import theano
from theano import shared, function from theano import shared, function
import theano.tensor as T import theano.tensor as T
...@@ -410,8 +411,20 @@ def test_neibs_grad_verify_grad_warp_centered(): ...@@ -410,8 +411,20 @@ def test_neibs_grad_verify_grad_warp_centered():
except NotImplementedError: except NotImplementedError:
pass pass
def test_neibs2images_crash_on_grad():
# say we had images of size (2,3,20,20)
# then we extracted 2x2 neighbors on this, we get (2*3*10*10, 4)
neibs = T.dmatrix()
neibs_val = numpy.random.rand(600,4)
to_images = T.sum(neibs2images(neibs, (2,2), (2,3,20,20)))
g = T.grad(to_images, neibs)
fn = theano.function([neibs], to_images)
print "Compiled"
fn(neibs_val)
if __name__ == '__main__': if __name__ == '__main__':
#test_neibs_gpu() #test_neibs_gpu()
#test_neibs() #test_neibs()
test_neibs_grad_verify_grad() #test_neibs_grad_verify_grad()
test_neibs2images_crash_on_grad()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论