Giter Site home page Giter Site logo

LKJ follow-up about bijectors.jl HOT 5 OPEN

turinglang avatar turinglang commented on July 20, 2024
LKJ follow-up

from bijectors.jl.

Comments (5)

devmotion avatar devmotion commented on July 20, 2024

Additionally we might want to:

  • Define the bijector on the Cholesky factor directly
  • Map it to a parameter vector instead of a matrix

from bijectors.jl.

torfjelde avatar torfjelde commented on July 20, 2024

Additionally we might want to:

  • Define the bijector on the Cholesky factor directly
  • Map it to a parameter vector instead of a matrix

This has now been done in #246 👍

from bijectors.jl.

torfjelde avatar torfjelde commented on July 20, 2024

Worth pointing out that the comments on numerical issues in TuringLang/DynamicPPL.jl#485 are talking about ForwardDiff, so would be curious to see whether usage of the rrule is helpful or not.

from bijectors.jl.

harisorgn avatar harisorgn commented on July 20, 2024

Worth pointing out that the comments on numerical issues in TuringLang/DynamicPPL.jl#485 are talking about ForwardDiff

The issue with ForwardDiff was more about correctness there, as I was not expecting a Dual with a single partial when differentiating wrt LKJ samples. We get numerical issues without ForwardDiff as well, that probably have to do with the numerical stability of the inverse link

function _inv_link_chol_lkj(y::AbstractVector)
K = _triu1_dim_from_length(length(y))
W = similar(y, K, K)
idx = 1
@inbounds for j in 1:K
W[1, j] = 1
for i in 2:j
z = tanh(y[idx])
idx += 1
tmp = W[i - 1, j]
W[i - 1, j] = z * tmp
W[i, j] = tmp * sqrt(1 - z^2)
end
for i in (j + 1):K
W[i, j] = 0
end
end
return W
end
as discussed in the same PR.

Numerical issues directly related with ForwardDiff were observed in #253 (comment) , which we treated by explicitly wrapping matrix with Hermitian to avoid the check.

from bijectors.jl.

harisorgn avatar harisorgn commented on July 20, 2024

The issue with ForwardDiff was more about correctness there

Just adding this here as well to move the discussion from the DynamicPPL PR. The numerical issues when sampling seem to be ForwardDiff-related indeed. See TuringLang/DynamicPPL.jl#485 (comment) for a simple test case, which gives loads of numerical issues when sampling with NUTS and Duals are passed through, but it seems to work fine with ReverseDiff.

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.