You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>f(x) =8x +10*sin(x)
f (generic function with 1 method)
julia>function ChainRulesCore.rrule(::typeof(f), x)
y =f(x)
function∇f(Δ)
∇ =8+10*cos(x)
@show ∇ Δ
return ChainRulesCore.NoTangent(), Δ * ∇
endreturn y, ∇f
end
julia>test_rrule(f, 2);
∇ =3.838531634528576
Δ =2.31
∇ =3.838531634528576
Δ =2.31
test_rrule: f on Int64: Test Failed at /home/somvt/.julia/packages/ChainRulesTestUtils/AX7fv/src/testers.jl:278
Expression: ad_cotangent isa NoTangent
Evaluated:8.86700807576101isa NoTangent
...
Test Summary:| Pass Fail Total
test_rrule: f on Int64 |415
ERROR: Some tests did not pass:4 passed, 1 failed, 0 errored, 0 broken.
the error message is confusing, we could special case it for actual::AbstractFloat, expected::NoTangent as suggested by @oxinabox
The text was updated successfully, but these errors were encountered:
Similar there are some other cases like AbstractVector{<:Interger} that really represent AbstractVector{<:AbstractFloat}.
We can check the primal type and see if it is one we automatically generated a NoTangent() from and then tell the user that if the are using this type then we can not be sure if they mean to use it as a non-differentiabled quantity like an index (our default assumption) or if they are using it to represent a continuous differentiable quantity.
For the particular case of integers we mike want to suggest rather than ⊢ but just plain testing on floating point values, since finite differencing is going to end up testing your primal function on floating point values anyway once you perturb it.
Though you might have a AD special case rule. (I don't think anyone really should) JuliaDiff/FiniteDifferences.jl#188 (comment)
e.g. example by @SomTambe
the error message is confusing, we could special case it for
actual::AbstractFloat, expected::NoTangent
as suggested by @oxinaboxThe text was updated successfully, but these errors were encountered: