Skip to content

SelectTransform with single index #181

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

Merged
merged 6 commits into from
Oct 2, 2020
Merged

Conversation

willtebbutt
Copy link
Member

The output SelectTransform(5)(some_vector) should really be a scalar, however, this currently doesn't work. It is important that this works so that (for example) a single dimension of a vector-valued input can be passed to kernels that can't handle vector-valued inputs, such as kernels constructed via PeriodicTransform.

This PR addresses this issue by making this possible.

@willtebbutt willtebbutt requested a review from sharanry October 1, 2020 14:28
@willtebbutt
Copy link
Member Author

@molet could you check that this fixes your problem?

@molet
Copy link
Contributor

molet commented Oct 1, 2020

@molet could you check that this fixes your problem?

Thanks a lot @willtebbutt for working on it! Now it seems to be working nicely:

using KernelFunctions, Zygote, AxisArrays
n = 100;
data = Matrix(hcat(collect(1:n), rand(n))');
a = AxisArray(data, features=[:time, :load], idx=collect(1:n));
k(θ) = TransformedKernel(TransformedKernel(
    TransformedKernel(ExponentialKernel(), ScaleTransform(θ[1])), 
    PeriodicTransform(1/24.0)),
    SelectTransform(:time)
);
o(θ) = sum(kernelmatrix(k(θ), a));
o([2.3])
1515.157184696975
Zygote.gradient(o, [2.3])
([294.83700581618575],)

Copy link
Contributor

@molet molet left a comment

Choose a reason for hiding this comment

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

LGTM

@willtebbutt
Copy link
Member Author

@theogf anything else you need?

@theogf
Copy link
Member

theogf commented Oct 1, 2020

Nope it's all good!

@willtebbutt willtebbutt merged commit a461737 into master Oct 2, 2020
@willtebbutt willtebbutt deleted the wct/single-index-selection branch October 2, 2020 09:29
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.

3 participants