16914cec3cababd56e18ac775339469f35bf4fa6,GPflow/conditionals.py,,conditional,#,5

Before Change


    // compute kernel stuff
    num_data = tf.shape(X)[0]
    Kmn = kern.K(X, Xnew)
    Kmm = kern.K(X) + eye(num_data)
    Lm = tf.cholesky(Kmm)

    // Compute the projection matrix A
    A = tf.matrix_triangular_solve(Lm, Kmn, lower=True)

    // compute the covariance due to the conditioning
    if full_cov:
        fvar = kern.K(Xnew) - tf.matmul(tf.transpose(A), A)
        fvar = tf.tile(tf.expand_dims(fvar, 2), [1, 1, num_columns])
    else:
        fvar = kern.Kdiag(Xnew) - tf.reduce_sum(tf.square(A), 0)
        fvar = tf.tile(tf.expand_dims(fvar, 1), [1, num_columns])

    // another backsubstitution in the unwhitened case
    if not whiten:
        A = tf.matrix_triangular_solve(tf.transpose(Lm), A, lower=False)

    // construct the conditional mean
    fmean = tf.matmul(tf.transpose(A), f)

    // add extra projected variance from q(f) if needed
    if q_sqrt is not None:
        projected_var = []
        for d in range(num_columns):
            if q_sqrt.get_shape().ndims == 2:
                LTA = A * q_sqrt[:, d:d + 1]
            elif q_sqrt.get_shape().ndims == 3:
                L = tf.user_ops.triangle(q_sqrt[:, :, d], "lower")
                LTA = tf.matmul(tf.transpose(L), A)
            else:  // pragma no cover
                raise ValueError("Bad dimension for q_sqrt: %s" %
                                 str(q_sqrt.get_shape().ndims))

After Change


    // compute kernel stuff
    num_data = tf.shape(X)[0]
    Kmn = kern.K(X, Xnew)
    Kmm = kern.K(X) + eye(num_data) * 1e-6
    Lm = tf.cholesky(Kmm)

    // Compute the projection matrix A
    A = tf.matrix_triangular_solve(Lm, Kmn, lower=True)

    // compute the covariance due to the conditioning
    if full_cov:
        fvar = kern.K(Xnew) - tf.matmul(tf.transpose(A), A)
        fvar = tf.tile(tf.expand_dims(fvar, 2), [1, 1, num_columns])
    else:
        fvar = kern.Kdiag(Xnew) - tf.reduce_sum(tf.square(A), 0)
        fvar = tf.tile(tf.expand_dims(fvar, 1), [1, num_columns])

    // another backsubstitution in the unwhitened case
    if not whiten:
        A = tf.matrix_triangular_solve(tf.transpose(Lm), A, lower=False)

    // construct the conditional mean
    fmean = tf.matmul(tf.transpose(A), f)

    // add extra projected variance from q(f) if needed
    if q_sqrt is not None:
        projected_var = []
        for d in range(num_columns):
            if q_sqrt.get_shape().ndims == 2:
                LTA = A * q_sqrt[:, d:d + 1]
            elif q_sqrt.get_shape().ndims == 3:
                L = tf.user_ops.triangle(q_sqrt[:, :, d], "lower")
                LTA = tf.matmul(tf.transpose(L), A)
            else:  // pragma no cover
                raise ValueError("Bad dimension for q_sqrt: %s" %
                                 str(q_sqrt.get_shape().ndims))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 2

Instances


Project Name: GPflow/GPflow
Commit Name: 16914cec3cababd56e18ac775339469f35bf4fa6
Time: 2016-04-14
Author: james.hensman@gmail.com
File Name: GPflow/conditionals.py
Class Name:
Method Name: conditional


Project Name: NifTK/NiftyNet
Commit Name: 8db30b2681160d42fe80f5fc025de128dd75a0d4
Time: 2018-07-23
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/layer/crf.py
Class Name: CRFAsRNNLayer
Method Name: layer_op


Project Name: NifTK/NiftyNet
Commit Name: 135a56e0935fbb04811f8ce7b9f514f498212f71
Time: 2018-07-25
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/layer/crf.py
Class Name: CRFAsRNNLayer
Method Name: layer_op


Project Name: OpenNMT/OpenNMT-py
Commit Name: 7732f27b85819cfb98388a498f59abc1bfd53f28
Time: 2019-01-31
Author: dylan.flaute@gmail.com
File Name: onmt/modules/structured_attention.py
Class Name: MatrixTree
Method Name: forward