Conversation
Codecov Report
@@ Coverage Diff @@
## master #418 +/- ##
==========================================
+ Coverage 92.25% 92.39% +0.13%
==========================================
Files 14 14
Lines 775 776 +1
==========================================
+ Hits 715 717 +2
+ Misses 60 59 -1
Continue to review full report at Codecov.
|
| (::ProjectTo{<:Number})(dx::Number) = dx | ||
| (::ProjectTo{<:Real})(dx::Real) = dx |
There was a problem hiding this comment.
Won't these work already, via the generic fallback, ProjectTo{T}(dx::T)?
There was a problem hiding this comment.
Seems not.
Without this it breaks.
Which is weird as the method error says the method is there.
LinearAlgebra: dense structured matrices: Error During Test at /home/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/test/projection.jl:175
Test threw exception
Expression: pherm(reshape(1:9, 3, 3) .+ im) == [1.0 3.0 5.0; 3.0 5.0 7.0; 5.0 7.0 9.0]
MethodError: no method matching (::ProjectTo{ComplexF64, NamedTuple{(), Tuple{}}})(::Complex{Int64})
Closest candidates are:
(::ProjectTo{T, D} where D<:NamedTuple)(::T) where T at /home/oxinabox/JuliaEnvs/ChainRulesWorld/ChainRulesCore.jl/src/projection.jl:111
```
|
NB: This isn't just an alternative implementation of #417 to address edge cases like JuliaDiff/ForwardDiff.jl#538 with strange number types. It also completely removes the idea that gradients of Integers should be floats, on which I thought there was consensus. We can discuss of course, but we did already discuss at length. What's the argument for changing this? |
Correct, sorry for the incorrect title. Fixed now I am happy with option 1 or option 2. But I am more than happy to stick to option 1. |
Apply suggestions from code review Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com> remove redundant real
|
My vote is option 1 then, with the tidier code here copied back & a few lines like |
|
I like that also. Good. |
For reference, I think the argument we had was the integers really are special. It's a compromise between knowing that they are really categorical, and every calculus 101 lecture which uses them as representatives of the real line, which happen to be quick to write on the blackboard. In this lecture there is certainly no expectation that the gradients also be integers; but there is an expectation they be real. |
Alternative to #417
which also says to leave integers alone as well.
Which @DhairyaLGandhi likes the idea of.
(I can see that it might lead to some faster code and avoid allocations)
This option basically says:
All subtypes of
Realrepresent the same subspace: all of Real.So if you give me one that is not a
AbstractFloatsubtype (.e.gIntegerorDual) I am just going to leave it alone.But if you give me a
AbstractFloat, I will fix the precision to match what i saw in the primal pass.