Skip to content
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

Batch Single dim derivative test is broken #76

Closed
killah-t-cell opened this issue Oct 9, 2021 · 0 comments · Fixed by #190
Closed

Batch Single dim derivative test is broken #76

killah-t-cell opened this issue Oct 9, 2021 · 0 comments · Fixed by #190
Assignees

Comments

@killah-t-cell
Copy link
Contributor

This test is broken

https://github.com/SciML/Quadrature.jl/blob/f913f39d9766a5d15f3829c51155ab3b655269d3/test/derivative_tests.jl#L137

The problem occurs with dp2. It throws a LoadError: DimensionMismatch("variable with size(x) == (1, 15) cannot have a gradient with size(dx) == (15,)")

https://github.com/SciML/Quadrature.jl/blob/f913f39d9766a5d15f3829c51155ab3b655269d3/test/derivative_tests.jl#L133

Which causes the test to break.

For convenience, here is an MWE one can use to test.

using Quadrature, Cuba, Cubature, Zygote, FiniteDiff, ForwardDiff
using Test

### Batch Single dim
f(x,p) = x*p[1].+p[2]*p[3]

lb =1.0
ub = 3.0
p = [2.0, 3.0, 4.0]
prob = QuadratureProblem(f,lb,ub,p)

function testf3(lb,ub,p; f=f)
    prob = QuadratureProblem(f,lb,ub,p, batch = 10, nout=1)
    solve(prob, CubatureJLh(); reltol=1e-3,abstol=1e-3)[1]
end

dp1 = ForwardDiff.gradient(p->testf3(lb,ub,p),p)
dp2 = Zygote.gradient(p->testf3(lb,ub,p),p)[1] # LoadError: DimensionMismatch("variable with size(x) == (1, 15) cannot have a gradient with size(dx) == (15,)")
dp3 = FiniteDiff.finite_difference_gradient(p->testf3(lb,ub,p),p)

@test dp1  dp3 #passes
@test dp2  dp3 # THIS IS BROKEN
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 a pull request may close this issue.

2 participants