* Verified StructuredDotGradCSR (everything looks ok). Added more loops around

unit test just to make sure. Also changed dimensions of matrix in unit test not to be square.
上级 19239b85
...@@ -1193,7 +1193,7 @@ class StructuredDotGradCSR(gof.Op): ...@@ -1193,7 +1193,7 @@ class StructuredDotGradCSR(gof.Op):
const npy_int32 * __restrict__ indptr = (npy_int32 *)%(_indptr)s->data; const npy_int32 * __restrict__ indptr = (npy_int32 *)%(_indptr)s->data;
const npy_int32 * __restrict__ indices = (npy_int32 *)%(_indices)s->data; const npy_int32 * __restrict__ indices = (npy_int32 *)%(_indices)s->data;
// loop over rows // loop over columns of sparse matrix
for (npy_int32 i = 0; i < N; ++i) for (npy_int32 i = 0; i < N; ++i)
{ {
// for each non-null value in the sparse row // for each non-null value in the sparse row
......
...@@ -153,15 +153,19 @@ class T_conversion(unittest.TestCase): ...@@ -153,15 +153,19 @@ class T_conversion(unittest.TestCase):
import scipy.sparse as sp import scipy.sparse as sp
class test_structureddot(unittest.TestCase): class test_structureddot(unittest.TestCase):
def setUp(self):
unittest_tools.seed_rng()
def test_structuredot(self): def test_structuredot(self):
bsize = 2 bsize = 2
spmat = sp.csc_matrix((5,5))
spmat[0,1] = 1 # iterate 10 times just to make sure (cannot get this wrong !)
spmat[0,2] = 2 for i in range(10):
spmat[1,2] = 3 spmat = sp.csc_matrix((4,6))
spmat[1,4] = 4 for i in range(5):
spmat[3,4] = 5 x = numpy.floor(numpy.random.rand()*spmat.shape[0])
y = numpy.floor(numpy.random.rand()*spmat.shape[1])
spmat[x,y] = numpy.random.rand()*10
kerns = tensor.dvector('kerns') kerns = tensor.dvector('kerns')
images = tensor.dmatrix('images') images = tensor.dmatrix('images')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论