Skip to content

Commit

Permalink
Rename transpose => to adjoint
Browse files Browse the repository at this point in the history
  • Loading branch information
awav committed Apr 25, 2019
1 parent 539c105 commit 8e3e4e8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions gpflow/conditionals/sample_conditionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def _sample_conditional(Xnew: tf.Tensor,
if full_cov:
# mean: [..., N, P]
# cov: [..., P, N, N]
mean_for_sample = tf.linalg.transpose(mean) # [..., P, N]
mean_for_sample = tf.linalg.adjoint(mean) # [..., P, N]
samples = sample_mvn(mean_for_sample, cov, 'full', num_samples=num_samples) # [..., (S), P, N]
samples = tf.linalg.transpose(samples) # [..., (S), P, N]
samples = tf.linalg.adjoint(samples) # [..., (S), P, N]
else:
# mean: [..., N, P]
# cov: [..., N, P] or [..., N, P, P]
Expand Down
4 changes: 2 additions & 2 deletions gpflow/conditionals/uncertain_conditionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def uncertain_conditional(Xnew_mu: tf.Tensor,
eKuffu = expectation(pXnew, (kernel, feature), (kernel, feature)) # [N, M, M] (psi2)
Luu_tiled = tf.tile(Luu[None, :, :], [num_data, 1, 1]) # remove this line, once issue 216 is fixed
Li_eKuffu = tf.linalg.triangular_solve(Luu_tiled, eKuffu, lower=True)
Li_eKuffu_Lit = tf.linalg.triangular_solve(Luu_tiled, tf.linalg.transpose(Li_eKuffu), lower=True) # [N, M, M]
Li_eKuffu_Lit = tf.linalg.triangular_solve(Luu_tiled, tf.linalg.adjoint(Li_eKuffu), lower=True) # [N, M, M]
cov = tf.linalg.matmul(q_sqrt_r, q_sqrt_r, transpose_b=True) # [D, M, M]

if mean_function is None or isinstance(mean_function, mean_functions.Zero):
Expand All @@ -87,7 +87,7 @@ def uncertain_conditional(Xnew_mu: tf.Tensor,
# einsum isn't able to infer the rank of e_mean_Kuf, hence we explicitly set the rank of the tensor:
e_mean_Kuf = tf.reshape(e_mean_Kuf, [num_data, num_func, num_ind])
e_fmean_mean = tf.einsum("nqm,mz->nqz", e_mean_Kuf, Lit_q_mu) # [N, D, D]
e_related_to_mean = e_fmean_mean + tf.linalg.transpose(e_fmean_mean) + e_mean_mean
e_related_to_mean = e_fmean_mean + tf.linalg.adjoint(e_fmean_mean) + e_mean_mean

if full_output_cov:
fvar = (
Expand Down
6 changes: 3 additions & 3 deletions gpflow/conditionals/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def base_conditional(

# another backsubstitution in the unwhitened case
if not white:
A = tf.linalg.triangular_solve(tf.linalg.transpose(Lm), A, lower=False)
A = tf.linalg.triangular_solve(tf.linalg.adjoint(Lm), A, lower=False)

# construct the conditional mean
f_shape = tf.concat([leading_dims, [M, num_func]], 0) # [..., M, R]
Expand All @@ -95,7 +95,7 @@ def base_conditional(
fvar = fvar + tf.reduce_sum(tf.square(LTA), -2) # [R, N]

if not full_cov:
fvar = tf.linalg.transpose(fvar) # [N, R]
fvar = tf.linalg.adjoint(fvar) # [N, R]

return fmean, fvar # [N, R], [R, N, N] or [N, R]

Expand Down Expand Up @@ -308,7 +308,7 @@ def fully_correlated_conditional_repeat(Kmn, Kmm, Knn, f, *, full_cov=False, ful

# another backsubstitution in the unwhitened case
if not white:
# A = tf.linalg.triangular_solve(tf.linalg.transpose(Lm), A, lower=False) # [M, K]
# A = tf.linalg.triangular_solve(tf.linalg.adjoint(Lm), A, lower=False) # [M, K]
raise NotImplementedError("Need to verify this.") # pragma: no cover

# f: [M, R]
Expand Down
2 changes: 1 addition & 1 deletion gpflow/expectations/cross_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def _E(p, lin_kern, feat1, rbf_kern, feat2, nghp=None):
:return: NxM1xM2
"""
return tf.linalg.transpose(expectation(p, (rbf_kern, feat2), (lin_kern, feat1)))
return tf.linalg.adjoint(expectation(p, (rbf_kern, feat2), (lin_kern, feat1)))
4 changes: 2 additions & 2 deletions gpflow/expectations/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _E(p, mean, _, kernel, feature, nghp=None):
:return: NxDxM
"""
return tf.linalg.transpose(expectation(p, (kernel, feature), mean))
return tf.linalg.adjoint(expectation(p, (kernel, feature), mean))


@dispatch.expectation.register((Gaussian, MarkovGaussian),
Expand All @@ -38,7 +38,7 @@ def _E(p, kernel, feature, mean, _, nghp=None):
:return: NxMxQ
"""
return tf.linalg.transpose(expectation(p, mean, (kernel, feature), nghp=nghp))
return tf.linalg.adjoint(expectation(p, mean, (kernel, feature), nghp=nghp))


@dispatch.expectation.register(Gaussian, mfn.Constant, NoneType, kernels.Kernel, InducingPoints)
Expand Down
2 changes: 1 addition & 1 deletion gpflow/expectations/quadratures.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def eval_func(x):

mu = tf.concat((p.mu[:-1, :], p.mu[1:, :]), 1) # Nx2D
cov_top = tf.concat((p.cov[0, :-1, :, :], p.cov[1, :-1, :, :]), 2) # NxDx2D
cov_bottom = tf.concat((tf.linalg.transpose(p.cov[1, :-1, :, :]), p.cov[0, 1:, :, :]), 2)
cov_bottom = tf.concat((tf.linalg.adjoint(p.cov[1, :-1, :, :]), p.cov[0, 1:, :, :]), 2)
cov = tf.concat((cov_top, cov_bottom), 1) # Nx2Dx2D

return mvnquad(eval_func, mu, cov, nghp)
2 changes: 1 addition & 1 deletion gpflow/expectations/sums.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _E(p, kern1, feat1, kern2, feat2, nghp=None):

for k2 in kern1.kernels[:i]:
eKK = expectation(p, (k1, feat1), (k2, feat2), nghp=nghp)
eKK += tf.linalg.transpose(eKK)
eKK += tf.linalg.adjoint(eKK)
crossexps.append(eKK)
else:
for k1, k2 in itertools.product(kern1.kernels, kern2.kernels):
Expand Down
2 changes: 1 addition & 1 deletion gpflow/kernels/stationaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def scaled_square_dist(self, X, X2):
if X2 is None:
Xs = tf.reduce_sum(tf.square(X), axis=-1, keepdims=True)
dist = -2 * tf.matmul(X, X, transpose_b=True)
dist += Xs + tf.linalg.transpose(Xs)
dist += Xs + tf.linalg.adjoint(Xs)
return dist

Xs = tf.reduce_sum(tf.square(X), axis=-1)
Expand Down

0 comments on commit 8e3e4e8

Please sign in to comment.