提交 99cfc788 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add test for ConstructSparseFromList.infer_shape

上级 a4425b96
......@@ -3323,8 +3323,8 @@ class ConstructSparseFromList(gof.Op):
"""
:param x: a dense matrix that specify the output shape.
:param values: a dense matrix with the values to use for output.
:param ilist: a dense vector with the same lenght as the number of rows
then values. It specify where in the output to put
:param ilist: a dense vector with the same length as the number of rows
of values. It specify where in the output to put
the corresponding rows.
This create a sparse matrix with the same shape as `x`. Its
......
......@@ -39,7 +39,8 @@ from theano.sparse import (
MulSV, mul_s_v, StructuredAddSV, structured_add_s_v,
SamplingDot, sampling_dot,
Diag, diag, SquareDiagonal, square_diagonal,
EnsureSortedIndices, ensure_sorted_indices, clean)
EnsureSortedIndices, ensure_sorted_indices, clean,
ConstructSparseFromList, construct_sparse_from_list)
# Probability distributions are currently tested in test_sp2.py
#from theano.sparse import (
......@@ -402,6 +403,21 @@ class SparseInferShapeTester(utt.InferShapeTester):
csc_from_dense.__class__)
def test_sparse_from_list(self):
x = tensor.matrix('x')
vals = tensor.matrix('vals')
ilist = tensor.lvector('ilist')
out = construct_sparse_from_list(x, vals, ilist)
self._compile_and_check(
[x, vals, ilist],
[out],
[numpy.zeros((40, 10), dtype=config.floatX),
numpy.random.randn(12, 10).astype(config.floatX),
numpy.random.randint(low=0, high=40, size=(12,))],
ConstructSparseFromList
)
class T_AddMul(unittest.TestCase):
def testAddSS(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论