Skip to content

Commit 6324129

Browse files
committed
Merge branch 'master' into 3.2rc1
2 parents 1de0f86 + c7c86a0 commit 6324129

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

docs/source/notebooks/GP-MeansAndCovs.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,22 +1045,22 @@
10451045
}
10461046
],
10471047
"source": [
1048-
"def tanh_func(x, x1, x2, w, x0):\n",
1048+
"def tanh_func(x, ls1, ls2, w, x0):\n",
10491049
" \"\"\"\n",
1050-
" l1: Left saturation value\n",
1051-
" l2: Right saturation value\n",
1052-
" lw: Transition width\n",
1053-
" x0: Transition location.\n",
1050+
" ls1: left saturation value\n",
1051+
" ls2: right saturation value\n",
1052+
" w: transition width\n",
1053+
" x0: transition location.\n",
10541054
" \"\"\"\n",
1055-
" return (x1 + x2) / 2.0 - (x1 - x2) / 2.0 * tt.tanh((x - x0) / w)\n",
1055+
" return (ls1 + ls2) / 2.0 - (ls1 - ls2) / 2.0 * tt.tanh((x - x0) / w)\n",
10561056
"\n",
10571057
"ls1 = 0.05\n",
10581058
"ls2 = 0.6\n",
1059-
"lw = 0.3\n",
1059+
"w = 0.3\n",
10601060
"x0 = 1.0\n",
1061-
"cov = pm.gp.cov.Gibbs(1, tanh_func, args=(ls1, ls2, lw, x0))\n",
1061+
"cov = pm.gp.cov.Gibbs(1, tanh_func, args=(ls1, ls2, w, x0))\n",
10621062
" \n",
1063-
"wf = theano.function([], tanh_func(X, ls1, ls2, lw, x0))()\n",
1063+
"wf = theano.function([], tanh_func(X, ls1, ls2, w, x0))()\n",
10641064
"plt.plot(X, wf); plt.ylabel(\"tanh_func(X)\"); plt.xlabel(\"X\"); plt.title(\"Lengthscale as a function of X\");\n",
10651065
"\n",
10661066
"K = cov(X).eval()\n",

pymc3/gp/cov.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,16 @@ def square_dist(self, X, Xs=None):
490490
return tt.clip(sqd, 0.0, np.inf)
491491

492492
def full(self, X, Xs=None):
493-
X, Xs = self._slice(X, Xs)
494-
rx = self.lfunc(X, self.args)
495-
rx2 = tt.reshape(tt.square(rx), (-1, 1))
493+
rx = self.lfunc(tt.as_tensor_variable(X), self.args)
496494
if Xs is None:
495+
rz = self.lfunc(tt.as_tensor_variable(X), self.args)
496+
X, Xs = self._slice(X, Xs)
497497
r2 = self.square_dist(X, X)
498-
rz = self.lfunc(X, self.args)
499498
else:
499+
rz = self.lfunc(tt.as_tensor_variable(Xs), self.args)
500+
X, Xs = self._slice(X, Xs)
500501
r2 = self.square_dist(X, Xs)
501-
rz = self.lfunc(Xs, self.args)
502+
rx2 = tt.reshape(tt.square(rx), (-1, 1))
502503
rz2 = tt.reshape(tt.square(rz), (1, -1))
503504
return (tt.sqrt((2.0 * tt.outer(rx, rz)) / (rx2 + rz2))
504505
* tt.exp(-1.0 * r2 / (rx2 + rz2)))

0 commit comments

Comments
 (0)