Comments (8)
I don't think there's anything wrong here, it's just that it's numerically very unstable. If I run the code with an inserted print statement in the definition of the inverse-evaluation of CorrBijector
, I get the following as an input (i.e. the value in the unconstrained space that HMC is working with):
10×10 Array{Float64,2}:
0.0 -1630.14 -857.317 -8051.24 … -825.602 -1598.03 -1801.29
0.0 0.0 8426.06 25379.5 -5603.79 -6840.33 -3651.21
0.0 0.0 0.0 30092.8 -2565.67 -4733.44 -56.0023
0.0 0.0 0.0 0.0 -7583.1 -10285.7 8297.9
0.0 0.0 0.0 0.0 -4432.82 -6084.45 6599.2
0.0 0.0 0.0 0.0 … -23834.4 -31462.6 -55327.8
0.0 0.0 0.0 0.0 -33831.2 -42291.8 22720.5
0.0 0.0 0.0 0.0 0.0 42018.5 13520.2
0.0 0.0 0.0 0.0 0.0 0.0 32250.5
0.0 0.0 0.0 0.0 0.0 0.0 0.0
Now, that doesn't look too pretty. The "transformed" version (from unconstrained to constrained) is:
10×10 Array{Float64,2}:
1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
-1.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 1.0
I need to look more into the LKJ distribution to see how we can deal with this though. Possibly related: https://mc-stan.org/docs/2_18/functions-reference/cholesky-lkj-correlation-distribution.html
from bijectors.jl.
Actually, I wonder if this is just an initilization problem. Like if we tilted the initialization towards regions of the unconstrained space that actually mapped to meaningfully differentiable correlation matrices.
Edit: bad solution, I know, because then it's a different density.
from bijectors.jl.
No, this is fine. This is essentially what we do in Turing wit the "robust" init-methods. But this is more of an issue with Turing rather than Bijectors, no?
EDIT: As in, it's fine to change the initialization procedure, but not the actual distribution, yeah.
from bijectors.jl.
Possibly also related: #134
from bijectors.jl.
No, this is fine. This is essentially what we do in Turing wit the "robust" init-methods. But this is more of an issue with Turing rather than Bijectors, no?
Yeah, perhaps, though the real issue might be the numerical instability. If the "true" bijector exists and is really numerically stable, then it doesn't matter how it's initialized.
from bijectors.jl.
Just a data point that may be relevant to this issue - I noticed that LKJ seems to never work with NUTS (giving the above posdef error), but it does seems to work just fine with HMC. E.g.,
using Turing
@model function LKJ_demo(P)
y ~ LKJ(P, 1)
end
model = LKJ_demo(5)
m1 = sample(model, HMC(0.01, 20), MCMCThreads(), 1, 4) # Works
m2 = sample(model, NUTS(1, 0.65), MCMCThreads(), 1, 4) # Always fails
from bijectors.jl.
@bratslavia This is because NUTS has an adaptation phase where it will try out possibly "extreme" step-sizes, while HMC
is using the fixed-step size of 0.01 that you provide. As a result, numerical issues are more likely to show up when using NUTS
rather than HMC
(unless you specify a very large step-size).
from bijectors.jl.
So what is the current suggested workaround, if any?
Bratslavia's MWE is indeed perfectly indicative of what I have been experiencing, that, at least as long as using NUTS then probably, it is very likely to run into an error that will basically stop all sampling.
from bijectors.jl.
Related Issues (20)
- filldist, up1 not defined HOT 6
- Adding bijectors for OrderStatistic and JointOrderStatistics HOT 1
- Add API function to retrieve size of bijector output from bijector input HOT 1
- rational quadratic flows not supporting Float32 input HOT 1
- What to do with `CorrBijector` ? HOT 1
- Improve `PDVecBijector`
- Matrix factorization bijectors HOT 4
- Domain Error for VecCholeskyBijector bijector when calling logabsdetjac HOT 4
- Question on simplex bijector implementation HOT 9
- Can't apply Bijectors.ordered to TDist() and MvTDist() HOT 1
- Incorrect bijector for heterogeneous Product distribution HOT 3
- Radial flow to a simplex HOT 5
- Stackoverflow in custom bijector HOT 2
- Missing implementation of `Bijectors.bijector` for `arraydist` distributions. HOT 1
- Bijectors.ordered and MvLogNormal interaction .. only supported for unconstrained distributions. HOT 1
- `TruncatedBijectors` not defined in `Distributions` extension
- support ProductDistribution HOT 3
- Fixes to correlation bijectors
- Improve `with_logabsdet_jacobian` performance for `SimplexBijector` HOT 1
- Tests are failing for `VecCorrBijector` in _very_ rare scenarios
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bijectors.jl.