-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
local kernels #66
Comments
@YAY-C @liam-o-marsh |
I'm not even sure what the code of 'myL' does, sorry. |
follow-up: I tried to rewrite the custom laplacian kernel. Is there a place where it wouldn't behave like the old version? def my_laplacian_kernel_old(X, Y, gamma):
""" Compute Laplacian kernel between X and Y
.. todo::
Write the docstring
"""
def cdist(X, Y):
K = np.zeros((len(X),len(Y)))
for i,x in enumerate(X):
x = np.array([x] * len(Y))
d = np.abs(x-Y)
while len(d.shape)>1:
d = np.sum(d, axis=1) # several axis available for np > 1.7.0 (TODO shall we move this)
K[i,:] = d
return K
K = -gamma * cdist(X, Y)
np.exp(K, K)
return K
def my_laplacian_kernel(X, Y, gamma):
""" Compute Laplacian kernel between X and Y
.. todo::
Write the docstring
"""
assert X.shape[1:] == Y.shape[1:]
innerdims = X.ndim-1
transposer = tuple(range(1,X.ndim)) + (0,)
K = np.tensordot(X, Y.transpose(*transposer), innerdims)
K *= -gamma
np.exp(K, out=K)
return K |
The text was updated successfully, but these errors were encountered: