def test_square_diagonal(): for K in 1, 5: d = tensor.ivector() sd = sp.square_diagonal(d) f = theano.function([d], sd) n = numpy.zeros((K, K), dtype="int32") for i in range(K): n[i, i] = i assert numpy.all(n == f(range(K)).toarray())
def test_square_diagonal(): for K in 1, 5: d = tensor.ivector() sd = sp.square_diagonal(d) f = theano.function([d], sd) n = numpy.zeros((K, K), dtype='int32') for i in range(K): n[i, i] = i assert numpy.all(n == f(range(K)).toarray())
def d(x): return sp.sp_sum(sp.square_diagonal(x), sparse_grad=True)