Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7729cb4

Browse filesBrowse files
nuka137jjerphanjeremiedbbrth
authored
FIX RuntimeWarning by dividing by zero in test_kernel_gradient (#19396)
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz> Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
1 parent c61dcff commit 7729cb4
Copy full SHA for 7729cb4

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed

‎sklearn/gaussian_process/kernels.py

Copy file name to clipboardExpand all lines: sklearn/gaussian_process/kernels.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,9 +1686,9 @@ def __call__(self, X, Y=None, eval_gradient=False):
16861686
D = squareform(dists**2)[:, :, np.newaxis]
16871687

16881688
if self.nu == 0.5:
1689-
K_gradient = K[..., np.newaxis] * D \
1690-
/ np.sqrt(D.sum(2))[:, :, np.newaxis]
1691-
K_gradient[~np.isfinite(K_gradient)] = 0
1689+
denominator = np.sqrt(D.sum(axis=2))[:, :, np.newaxis]
1690+
K_gradient = K[..., np.newaxis] * \
1691+
np.divide(D, denominator, where=denominator != 0)
16921692
elif self.nu == 1.5:
16931693
K_gradient = \
16941694
3 * D * np.exp(-np.sqrt(3 * D.sum(-1)))[..., np.newaxis]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.