Giter Site home page Giter Site logo

Comments (4)

trappmartin avatar trappmartin commented on July 20, 2024 1

If instead an Array of TrackedReal's is used, everything works smooth.

from bijectors.jl.

trappmartin avatar trappmartin commented on July 20, 2024

Running the following code...

function f_test(θᴿ, x)
    K = 3
    μ = [0.5, 0.2, -0.5]
    @assert length(θᴿ) == K
    
    logpdf_mm(θ, x) = log(sum.* (x.-μ).^2))
    
    d = Dirichlet(K, 1.0)
    lp = logpdf_with_trans(d, invlink(d, θᴿ), true)
    lp += logpdf_mm(invlink(d, θᴿ), x)
    return lp
end

v, g = Tracker.forward((θ, x) -> f_test(θ, x), [0.3, 0.2, 0.5], 0.4)

will result in:

MethodError: no method matching Float64(::Flux.Tracker.TrackedReal{Float64})
Closest candidates are:
  Float64(::Real, !Matched::RoundingMode) where T<:AbstractFloat at rounding.jl:185
  Float64(::T<:Number) where T<:Number at boot.jl:725
  Float64(!Matched::Int8) at float.jl:60
  ...

from bijectors.jl.

trappmartin avatar trappmartin commented on July 20, 2024

This issue is related to the fact that θ is TrackedArray, which for some reasons breaks the differentiation.

Stacktrace:
 [1] convert(::Type{Float64}, ::Flux.Tracker.TrackedReal{Float64}) at ./number.jl:7
 [2] setindex!(::Array{Float64,1}, ::Flux.Tracker.TrackedReal{Float64}, ::Int64) at ./array.jl:769
 [3] invlink(::Dirichlet{Float64}, ::TrackedArray{…,Array{Float64,1}}, ::Type{Val{true}}) at /Users/martin/.julia/dev/Bijectors/src/Bijectors.jl:228

from bijectors.jl.

mohamed82008 avatar mohamed82008 commented on July 20, 2024

This is fixed now.

from bijectors.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.