JuliaDiff / JuliaDiff/ReverseDiff.jl
mean BigFloat precision
Closed
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 393
- Forks
- 60
- Avg merge
- 18h 24m
- Merged PRs (30d)
- 8
Description
I observed a loss of precision using ReverseDiff with respect to ForwardDiff on the following simple example:
julia> testprecision()
type precision eps(T) = 1.7272337110188889250772703725600799142232e-77
ForwardDiff error = 0.0000000000000000000000000000000000000000e+00
ReverseDiff error = 8.6560832651618551196119417711416155844212e-19
Is it expected?
Thanks!
using Statistics, LinearAlgebra
using ForwardDiff, ReverseDiff, Printf
setprecision(2 ^ 8)
function testprecision(n::Int64 = 1_000, T::DataType = BigFloat)
x = rand(T, n)
f(x) = mean(x .^ 3)
gf = ForwardDiff.gradient(f, x)
gr = ReverseDiff.gradient(f, x)
gth = 3 * x .^ 2 / n
@printf "type precision eps(T) = %4.40e \n\n" eps(T)
@printf "ForwardDiff error = %4.40e \n" norm(gf - gth)
@printf "ReverseDiff error = %4.40e \n" norm(gr - gth)
nothing
end
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
No repository file or test is named. Start by running the provided Julia testprecision example with BigFloat, then trace the ForwardDiff.gradient and ReverseDiff.gradient entry points to compare their precision handling; done means determining whether the discrepancy is expected and documenting or correcting the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100