Skip to content

Commit f71a428

Browse files
committed
moved some general functions into util
1 parent 24b464f commit f71a428

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pymc3/gp/util.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
from scipy.cluster.vq import kmeans
22
import numpy as np
3+
import pymc3 as pm
4+
import theano.tensor as tt
5+
6+
7+
cholesky = pm.distributions.dist_math.Cholesky(nofail=True, lower=True)
8+
solve_lower = tt.slinalg.Solve(A_structure='lower_triangular')
9+
solve_upper = tt.slinalg.Solve(A_structure='upper_triangular')
10+
solve = tt.slinalg.Solve(A_structure='general')
11+
12+
13+
def infer_shape(X, n_points=None):
14+
if n_points is None:
15+
try:
16+
n_points = np.int(X.shape[0])
17+
except TypeError:
18+
raise TypeError("Cannot infer n_points, provide as an argument")
19+
return n_points
20+
21+
22+
def stabilize(K):
23+
""" adds small diagonal to a covariance matrix """
24+
return K + 1e-6 * tt.identity_like(K)
25+
326

427
def kmeans_inducing_points(n_inducing, X):
528
# first whiten X

0 commit comments

Comments
 (0)