FluxML / FluxML/Tracker.jl

Distances.pairwise fails on TrackedArray

Open
#59 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
54
Forks
37
Avg merge
5h 49m
Merged PRs (30d)
1

Description

```julia
julia> using Distances, Flux

julia> pairwise(SqEuclidean(), param([1 2; 3 4]), dims = 2)
ERROR: MethodError: no method matching Float64(::Tracker.TrackedReal{Float64})
Closest candidates are:
Float64(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:194
Float64(::T<:Number) where T<:Number at boot.jl:718
Float64(::Int8) at float.jl:60
...
Stacktrace:
[1] convert(::Type{Float64}, ::Tracker.TrackedReal{Float64}) at ./number.jl:7
[2] setindex!(::Array{Float64,1}, ::Tracker.TrackedReal{Float64}, ::Int64) at ./array.jl:766
[3] sumsq_percol(::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/common.jl:107
[4] _pairwise!(::Array{Tracker.TrackedReal{Float64},2}, ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/metrics.jl:600
[5] #pairwise!#2(::Int64, ::typeof(pairwise!), ::Array{Tracker.TrackedReal{Float64},2}, ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/generic.jl:184
[6] #pairwise! at ./none:0 [inlined]
[7] #pairwise#4(::Int64, ::typeof(pairwise), ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at /home/user/.julia/packages/Distances/jwhuc/src/generic.jl:213
[8] (::getfield(Distances, Symbol("#kw##pairwise")))(::NamedTuple{(:dims,),Tuple{Int64}}, ::typeof(pairwise), ::SqEuclidean, ::TrackedArray{…,Array{Float64,2}}) at ./none:0
[9] top-level scope at REPL[2]:1
```

Could you please make it work? I think the problem is [here](https://github.com/JuliaStats/Distances.jl/blob/5dbf9b837989d5c9c6a78b918ca2518c6e4ac313/src/common.jl#L104), but I don't know how to fix it (probably needs to be done in Distances.jl?)

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.