示例#1
0
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())
示例#2
0
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())
示例#3
0
 def d(x):
     return sp.sp_sum(sp.square_diagonal(x), sparse_grad=True)
示例#4
0
 def d(x):
     return sp.sp_sum(sp.square_diagonal(x), sparse_grad=True)