提交 b6584d8d authored 作者: Frederic's avatar Frederic

make infer_shape tests work in not square shape.

上级 b389bcf4
......@@ -1527,7 +1527,7 @@ class SpSumTester(utt.InferShapeTester):
for format in sparse.sparse_formats:
for axis in self.possible_axis:
variable, data = sparse_random_inputs(format,
shape=(10, 10))
shape=(9, 10))
self._compile_and_check(variable,
[self.op(variable[0], axis=axis)],
data,
......@@ -1538,7 +1538,7 @@ class SpSumTester(utt.InferShapeTester):
for axis in self.possible_axis:
for struct in [True, False]:
variable, data = sparse_random_inputs(format,
shape=(10, 10))
shape=(9, 10))
verify_grad_sparse(
self.op_class(axis=axis, sparse_grad=struct),
data,
......@@ -1744,7 +1744,7 @@ class Remove0Tester(utt.InferShapeTester):
assert result.size == target.size, msg
def test_infer_shape(self):
mat = (numpy.arange(9) + 1).reshape((3, 3))
mat = (numpy.arange(12) + 1).reshape((4, 3))
mat[0, 1] = mat[1, 0] = mat[2, 2] = 0
x_csc = theano.sparse.csc_matrix(dtype=theano.config.floatX)
......
......@@ -242,7 +242,8 @@ class TestRepeatOp(utt.InferShapeTester):
def test_infer_shape(self):
for ndim in range(4):
x = T.TensorType(config.floatX, [False] * ndim)()
a = np.random.random((10, ) * ndim).astype(config.floatX)
shp = (numpy.arange(ndim) + 1) * 5
a = np.random.random(shp).astype(config.floatX)
for axis in self._possible_axis(ndim):
for dtype in tensor.discrete_dtypes:
......@@ -261,6 +262,9 @@ class TestRepeatOp(utt.InferShapeTester):
if axis is None:
r = np.random.random_integers(
5, size=a.size).astype(dtype)
elif a.size > 0:
r = np.random.random_integers(
5, size=a.shape[axis]).astype(dtype)
else:
r = np.random.random_integers(
5, size=(10,)).astype(dtype)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论