-
Notifications
You must be signed in to change notification settings - Fork 49
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
AD error with rat42 #338
Comments
@dpo I think we should better displayed what backend is associated to what when we display an For the gradient of |
Sorry, you’re right. However: julia> jac_residual(rat42_nls, x)
9×3 SparseMatrixCSC{Float64, Int64} with 27 stored entries:
-5.03261e-50 5.02995e-48 -4.52696e-47
-5.14752e-77 5.1448e-75 -7.20271e-74
-8.42023e-115 8.41577e-113 -1.76731e-111
-1.37737e-152 1.37664e-150 -3.85459e-149
-3.68555e-228 -0.0 -0.0
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN |
I suspect that it's related to this vector of |
Me too. That's very weird modeling. For info, with JuMP: julia> model = MathOptNLPModel(rat42())
julia> obj(model, x)
9111.7101
julia> grad(model, x)
3-element Vector{Float64}:
-4.494124501515864e-49
4.491747286612452e-47
-4.042572557951207e-46 The JuMP/NLS version is not in the repository, but: julia> model = Model()
julia> @variable(model, x[j = 1:3])
julia> set_start_value.(x, [100, 1, 0.1])
julia> for i = 1:9
@eval @NLexpression(model, $(Symbol("F$i")), y[$i, 1] - x[1] / (1 + exp(x[2] - x[3] * y[$i, 2])))
end
julia> rat42_nls = MathOptNLSModel(model, [F1, F2, F3, F4, F5, F6, F7, F8, F9])
julia> xx = [99.94710393753867, 1.6483148108416925, -12.429444473714828]
julia> obj(rat42_nls, xx)
9111.7101
julia> jac_residual(rat42_nls, xx)
9×3 SparseMatrixCSC{Float64, Int64} with 27 stored entries:
-5.03261e-50 5.02995e-48 -4.52696e-47
-5.14752e-77 5.1448e-75 -7.20271e-74
-8.42023e-115 8.41577e-113 -1.76731e-111
-1.37737e-152 1.37664e-150 -3.85459e-149
-3.68555e-228 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0 |
Actually, converting the array |
ReverseDiff is only marginally better: julia> grad(model, xx)
3-element Vector{Float64}:
-4.494124501515864e-49
NaN
NaN |
And, finally, julia> model = rat42(; gradient_backend = ADNLPModels.ZygoteADGradient)
julia> grad(model, xx)
3-element Vector{Float64}:
-4.494124501515864e-49
NaN
NaN |
I suppose the problem here is simply that we need problem scaling. The term |
I am not aware of any scaling in JuMP. They probably just do something smart if they encounter a division by |
Why would they have different arithmetic than Julia itself? |
Because they compute the derivative with a reverse pass directly on their expression tree. |
Even though the AD backend for the residual Jacobian is defined, it returns an empty Jacobian:
There is also an error with the gradient of the NLP model:
@amontoison @tmigot Any ideas?
The text was updated successfully, but these errors were encountered: