Skip to content

Add kappa to stationary Gabor kernel #79

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

Closed
wants to merge 5 commits into from
Closed

Add kappa to stationary Gabor kernel #79

wants to merge 5 commits into from

Conversation

sharanry
Copy link
Contributor

Since Gabor kernel is a Stationary and and Isotropic kernel, I thought it would be a good idea to add kappa of the form kappa(κ::GaborKernel, d::Real). Missed it earlier in #52 .

@theogf
Copy link
Member

theogf commented Apr 17, 2020

Could you just change the basekernel path? Then we can merge!

@sharanry
Copy link
Contributor Author

sharanry commented Apr 17, 2020

@willtebbutt @theogf @devmotion Is it ready to merge?

Comment on lines 57 to 58

kappa(κ::GaborKernel, x, y) = kappa(κ.kernel, x, y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this? Can't we just use the generic implementation in

kappa::Kernel, x, y) = kappa(κ, evaluate(metric(κ), x, y))
now that a metric is defined for the Gabor kernel?

Suggested change
kappa::GaborKernel, x, y) = kappa.kernel, x, y)

Copy link
Contributor Author

@sharanry sharanry Apr 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering why without this the test kappa(k, x, y) == kappa(k, evaluate(KernelFunctions.metric(k), x, y)) was failing without this line. There was an error in the kappa(::GaborKernel, d::Real).

Apparently, kappa(k::TransformedKernel, d) = kappa(k.kernel, d), so it doesn't do the transformation before applying the kernel using the distance measure. I think this is a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present fix is to modify the kappa to give the intended output of gabor kernel

function kappa::GaborKernel, d::Real)
    return kappa.kernel.kernels[1], (d/κ.ell)^2) * kappa.kernel.kernels[2], d/κ.p)
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not something we want to do since ell and p do not have to be scalar valued. It seems it just doesn't make sense to define kappa(::GaborKernel, ::Real) and metric(::GaborKernel), and we should just keep the old implementation of forwarding kappa to the underlying kernel? If we want to do any optimization based on the metric, it should be done in KernelProd (see the PR for its refactoring).

@devmotion
Copy link
Member

Unfortunately, IMO this PR should be closed since it is not guaranteed that parameters p and ell are scalar valued (see #79 (comment)).

@willtebbutt
Copy link
Member

To be honest, I'm a bit confused as to why we have this implemented as a kernel at all. It seems like something that would be best implemented by a helper function in terms of Prod. Am I missing something?

@devmotion
Copy link
Member

I agree, I'm still not fully convinced that we should have a separate type. We had a discussion about this when it was added (see #52 (comment) and the comments below). IIRC one argument for having a dedicated type was that otherwise the parameters of the Gabor kernel can't be accessed easily.

@sharanry
Copy link
Contributor Author

Yes accessing the Gabor's parameters was the only issue if it were just a simple function returning a KernelProduct. This would not affect making the kernel trainable in any way. If the parameters are not really necessary to be accessed, I can't seem to think of any other good reason to keep a separate type.

@sharanry
Copy link
Contributor Author

I don't think this PR has any value anymore. Gabor kernel is a KernelProduct now. kappa is still cannot be defined for it because it is not defined for KernelProduct. Should we consider refining it?

@theogf
Copy link
Member

theogf commented Oct 10, 2020

I guess we should close this PR because kappa only make sense for SimpleKernel

@sharanry sharanry closed this Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants