Beispiel #1
0
def test_diag():
    m = theano.sparse.csc_matrix()
    d = sp.diag(m)
    f = theano.function([m], d)
    f2 = theano.function([m], d.shape)
    for K in 1, 5:
        np_matrix = numpy.asarray(numpy.reshape(range(K ** 2), (K, K)), dtype=theano.config.floatX)
        diag = numpy.diagonal(np_matrix)
        sp_matrix = scipy.sparse.csc_matrix(np_matrix)

        assert numpy.all(diag == f(sp_matrix))
        assert f2(sp_matrix) == diag.shape
Beispiel #2
0
def test_diag():
    m = theano.sparse.csc_matrix()
    d = sp.diag(m)
    f = theano.function([m], d)
    f2 = theano.function([m], d.shape)
    for K in 1, 5:
        np_matrix = numpy.asarray(numpy.reshape(range(K**2), (K, K)),
                                  dtype=theano.config.floatX)
        diag = numpy.diagonal(np_matrix)
        sp_matrix = scipy.sparse.csc_matrix(np_matrix)

        assert numpy.all(diag == f(sp_matrix))
        assert f2(sp_matrix) == diag.shape
Beispiel #3
0
 def d(x):
     sp_x = theano.sparse.csc_from_dense(x)
     diag_x = sp.diag(sp_x)
     return diag_x.sum()
Beispiel #4
0
 def d(x):
     sp_x = theano.sparse.csc_from_dense(x)
     diag_x = sp.diag(sp_x)
     return diag_x.sum()