Comments (9)
Done, #20. The main improvement came from replacing log(1/x)
with -log(x)
thus eliminating an unnecessary division. New benchmarks:
julia> @btime invlink_simplex($y);
39.384 μs (1 allocation: 7.94 KiB)
julia> @btime invlink($d, $y);
39.020 μs (1 allocation: 7.94 KiB)
from bijectors.jl.
It looks to me like it's stable, but Mohamed the Master of Type Stability probably has a far better eye for that than me.
from bijectors.jl.
Hi @trappmartin !
Your implementation looks type stable but I think we will run into numerical issues when inverting this. The main numerical stability problems were from link
, invlink
was just modified accordingly to be its inverse. I do think however there is a performance issue in Bijectors. I looked into it, and it seems the @debug
sentences are causing some type instability. When removing them, and benchmarking I get:
julia> @btime invlink_simplex($y);
39.384 μs (1 allocation: 7.94 KiB)
julia> @btime invlink($d, $y);
43.395 μs (1 allocation: 7.94 KiB)
I assume the extra time is from the extra epsilon arithmetic that is done. The real difference is probably more when you use @inbounds
. So I guess what it boils down to is if we are willing to throw away the inverse property between link
and invlink
, then we can gain some extra performance with your implementation of invlink
.
from bijectors.jl.
I will also make a PR to fix the @debug
issues.
from bijectors.jl.
Sounds good. I wasn’t aiming for performance with my implementation but was surprised that the invlink is so much slower.
from bijectors.jl.
Maybe as a side note, it might be good to have internal functions that do not require to pass a distribution object. This would allow a knowledgeable user to use the transformations without instantiating a Distributions object. Similar to the StatsFuns package.
from bijectors.jl.
One last note. I think the invlink should be at least as fast as my code as I don’t optimise anything and invlink looks rather tuned. Your test shows that even after removing the @debug
the invlink is still slower. I guess we should think about improving the code as this gets called frequently during sampling.
from bijectors.jl.
@trappmartin The slowdown is from the epsilons to make invlink
a proper inverse of the numerically stable link
. Are you proposing making invlink
as fast as possible even if it is not a good inverse of the numerically stable link
?
from bijectors.jl.
No, I propose we try to get to code faster while keeping it numerical stable.
from bijectors.jl.
Related Issues (20)
- Zygote is broken for `Stacked` bijectors HOT 5
- 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
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.