提交 5cde49ac authored 作者: jojolalpin's avatar jojolalpin

Add test for theano.sparse.opt.sd_csc in test_opt.py

上级 9c7c3b8a
...@@ -152,3 +152,20 @@ def test_local_dense_from_sparse_sparse_from_dense(): ...@@ -152,3 +152,20 @@ def test_local_dense_from_sparse_sparse_from_dense():
# We should just have a deep copy. # We should just have a deep copy.
assert len(f.maker.fgraph.apply_nodes) == 1 assert len(f.maker.fgraph.apply_nodes) == 1
f([[1, 2], [3, 4]]) f([[1, 2], [3, 4]])
def test_sd_csc():
A = sp.rand(4, 5, density=0.60, format='csc', dtype=numpy.float32)
b = numpy.random.rand(5,2).astype(numpy.float32)
target = A*b
a_val = theano.tensor.as_tensor_variable(A.data)
a_ind = theano.tensor.as_tensor_variable(A.indices)
a_ptr = theano.tensor.as_tensor_variable(A.indptr)
nrows = theano.tensor.as_tensor_variable(numpy.int32(A.shape[0]))
b = theano.tensor.as_tensor_variable(b)
res = theano.sparse.opt.sd_csc(a_val, a_ind, a_ptr, nrows, b).eval()
assert (res==target).all()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论