Browse Source

[Fix] Fix laplacian_kernel and cosine_kernel between pairs of numpy vectors.

v0.2.x
jajupmochi 3 years ago
parent
commit
42acfd0236
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      gklearn/utils/kernels.py

+ 2
- 2
gklearn/utils/kernels.py View File

@@ -127,7 +127,7 @@ def linearkernel(x, y):


def cosine_kernel(x, y):
return np.dot(x, y) / (np.abs(x) * np.abs(y))
return np.dot(x, y) / (np.linalg.norm(x) * np.linalg.norm(y))


def sigmoid_kernel(x, y, gamma=None, coef0=1):
@@ -146,7 +146,7 @@ def laplacian_kernel(x, y, gamma=None):
if gamma is None:
gamma = 1.0 / len(x)

k = -gamma * np.abs(np.subtract(x, y))
k = -gamma * np.linalg.norm(np.subtract(x, y))
k = np.exp(k)
return k



Loading…
Cancel
Save