Esempio n. 1
0
 def f(r, y):
     PD = r.dot(r.T)
     L = gpu_cholesky(PD)
     A = gpu_solve_lower_triangular(L, y)
     AAT = theano.tensor.dot(A, A.T)
     B = AAT + theano.tensor.eye(N)
     LB = gpu_cholesky(B)
     return theano.tensor.sum(theano.tensor.log(theano.tensor.diag(LB)))
Esempio n. 2
0
 def f(r, y):
     PD = r.dot(r.T)
     L = gpu_cholesky(PD)
     A = gpu_solve_lower_triangular(L, y)
     AAT = theano.tensor.dot(A, A.T)
     B = AAT + theano.tensor.eye(N)
     LB = gpu_cholesky(B)
     return theano.tensor.sum(theano.tensor.log(theano.tensor.diag(LB)))
Esempio n. 3
0
def test_cholesky_grad():
    rng = np.random.RandomState(utt.fetch_seed())
    r = rng.randn(5, 5).astype(config.floatX)

    # The dots are inside the graph since Cholesky needs separable matrices

    # Check the default.
    utt.verify_grad(lambda r: gpu_cholesky(r.dot(r.T)), [r], 3, rng)
    # Explicit lower-triangular.
    utt.verify_grad(lambda r: GpuCholesky(lower=True)(r.dot(r.T)), [r], 3, rng)
    # Explicit upper-triangular.
    utt.verify_grad(lambda r: GpuCholesky(lower=False)(r.dot(r.T)), [r], 3, rng)
Esempio n. 4
0
def test_cholesky_grad():
    rng = np.random.RandomState(utt.fetch_seed())
    r = rng.randn(5, 5).astype(config.floatX)

    # The dots are inside the graph since Cholesky needs separable matrices

    # Check the default.
    yield (lambda: utt.verify_grad(lambda r: gpu_cholesky(r.dot(r.T)),
                                   [r], 3, rng))
    # Explicit lower-triangular.
    yield (lambda: utt.verify_grad(lambda r: GpuCholesky(lower=True)(r.dot(r.T)),
                                   [r], 3, rng))
    # Explicit upper-triangular.
    yield (lambda: utt.verify_grad(lambda r: GpuCholesky(lower=False)(r.dot(r.T)),
                                   [r], 3, rng))