ForwardDiff fails for Matern kernels when the two arguments are equal
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- julia
- Domain
- machine-learning
Research direction
Start by running the provided MWE with KernelFunctions v0.10.58 or later and ForwardDiff v1.0.0 or later, focusing on ForwardDiff.gradient for MaternKernel when both arguments are equal. Compare the result with unequal arguments, older package versions, and Zygote; done means the equal-argument gradient no longer returns NaNs while the existing cases continue to work.
Written by the indexing model from the issue text.
Description
I have a project in which I take gradients of Matern kernels with respect to an argument via ForwardDiff and was able to do so without issue until recently. When using KernelFunctions v0.10.58 or greater or ForwardDiff v1.0.0 or greater, however, calling ForwardDiff.gradient with respect to an argument on a Matern kernel returns a vector of NaNs when the two arguments to the kernel are equal. If I use Zygote instead I get a vector of zeros. MWE:
using KernelFunctions
using ForwardDiff
using Zygote
vec1 = randn(2)
vec2 = randn(2)
myfun(x) = MaternKernel(ν=2.1)(x, vec1)
ForwardDiff.gradient(myfun, vec1) # vector of NaNs
ForwardDiff.gradient(myfun, vec2) # works as expected
Zygote.gradient(myfun, vec1) # vector of 0s
Zygote.gradient(myfun, vec2) # works as expected
For reference, ForwardDiff.gradient(myfun, vec1) returns a vector of zeros with KernelFunctions v0.10.57 and ForwardDiff v0.10.38.
- Dominant language
- Julia
- Stars
- 276
- Forks
- 42
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGaussianProcesses/KernelFunctions.jl
-
Future plans?Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGaussianProcesses/KernelFunctions.jl#585 · 8 comments · 3 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
new kernel
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
JuliaGaussianProcesses/KernelFunctions.jl#533 · 1 reaction ·
-
Test custom rulesOpen
Difficulty 3/5 1-2 days Newbie friendliness 25/100
JuliaGaussianProcesses/KernelFunctions.jl#532 · 2 reactions ·
All issues in JuliaGaussianProcesses/KernelFunctions.jl
Similar issues
-
tagbot-manual
Difficulty 1/5 Under an hour Newbie friendliness 75/100
tshort/StaticCompiler.jl#191 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
SciML/SciMLSensitivity.jl#1703 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliaGPU/GPUCompiler.jl#1008 ·
Maintainers usually reply within 1 day
-
`biggs6` disagrees with CUTEst and is unbounded belowPossibly taken @timholy claimed this 1 day ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Cannot set point coordinates with `Range`s (or arbitrary arrays) using `Makie.Resampler` in `heatmap`Possibly taken @ffreyer claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day