-
Notifications
You must be signed in to change notification settings - Fork 35
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
PeriodicKernel
does not work with AD (see issue for work-around)
#389
Comments
I just reran the AD tests and it looks like using Note that our |
Why isn't there a period length parameter as in gpytorch? |
Because this would just be the lengthscale. You could achieve the same result with: p = [1.0, 2.0, 1.5]
k = with_lengthscale(PeriodicKernel(;r=rand(3)), p) where The |
Oh, I was independently trying to build the MaunaLoa example (I put the work-in-progress here: https://github.com/JuliaGaussianProcesses/EcosystemIntegrationTesting/blob/main/api_testing/mauna_loa_example/script.jl as a Pluto.jl notebook) and ran into the same bug. Here's code to reproduce the bug: using AbstractGPs
using ParameterHandling
function build_gp(th)
return GP(th.s^2 * with_lengthscale(PeriodicKernel(; r=[th.l/2]), th.p))
end
th = (; s = positive(exp(0.0)), l=positive(exp(1.0)), p=positive(exp(0.0)))
thflat, unflatten = ParameterHandling.value_flatten(th)
x = rand(5)
y = rand(5)
function loss(th)
f=build_gp(th)
return -logpdf(f(x, 0.01), y)
end
loss_packed = loss ∘ unflatten
using Zygote
Zygote.gradient(loss_packed, thflat) |
@david-vicente the following two lines give equivalent kernels (in 1D): k1 = with_lengthscale(PeriodicKernel(; r=[wiggle_scale / 2]), period)
k2 = with_lengthscale(SqExponentialKernel(), wiggle_scale) ∘ PeriodicTransform(1/period) and we might want to provide (Note that |
Thank you @st--. I did look to the k1 = with_lengthscale(PeriodicKernel(; r=[wiggle_scale / 2]), period)
k2 = with_lengthscale(SqExponentialKernel(), wiggle_scale) ∘ PeriodicTransform(1/period) to its documentation? |
PeriodicKernel
does not work with AD (see issue for work-around)
@david-vicente I've just added the finished example to AbstractGPs: JuliaGaussianProcesses/AbstractGPs.jl#240 Yes it'd be great to improve the documentation. Would you be up for making the change and opening a PR? :) |
You could also add the |
Can we do the same for multi-dimensional inputs? |
It would work in exactly the same way if we would make |
Fixed by #531 |
Hi.
I noticed that the PeriodicKernel is failling AD tests and I would like to implement the Mauna Loa GPR example. I tried looking for discussion regarding this issue in past Issues but there isn't much. Is the problem an instance of "it is doable but no one has had the time yet" or is it pending because of stuff that depends on AD packages?
Thanks!
The text was updated successfully, but these errors were encountered: