def test_GetItem2Lists(self):
a, A = sparse_random_inputs('csr', (4, 5))
b, B = sparse_random_inputs('csc', (4, 5))
y = a[0][[0, 0, 1, 3], [0, 1, 2, 4]]
z = b[0][[0, 0, 1, 3], [0, 1, 2, 4]]
fa = theano.function([a[0]], y)
fb = theano.function([b[0]], z)
t_geta = fa(A[0])
t_getb = fb(B[0])
s_geta = numpy.asarray(scipy.sparse.csr_matrix(A[0])[[0, 0, 1, 3], [0, 1, 2, 4]])
s_getb = numpy.asarray(scipy.sparse.csc_matrix(B[0])[[0, 0, 1, 3], [0, 1, 2, 4]])
utt.assert_allclose(t_geta, s_geta)
utt.assert_allclose(t_getb, s_getb)
评论列表
文章目录