Comments (13)
ahh, ok, my bad, got it.
from dhod.
Worst comes to worst, you could always use the scipy implementation to train a simple MLP surrogate.
from dhod.
Ok, so for future reference, here is the scipy implementation, they have a few fixes for several special cases, but they still admit it can fail to converge from time to time:
https://github.com/scipy/scipy/blob/master/scipy/special/lambertw.pxd
For now however, I'm happy with just limiting the number of iterations to 100, I'll make a proper PR to TFP to propose a better fix.
Can now sample without problems 10^6 radii and get perfect match compared to theory:
10^6 sample time:
- numpy: 298ms
- TF (GPU accelerated): 81.9ms
from dhod.
Also linked to the reference above, here is a cute python implementation:
https://github.com/CullanHowlett/NFWdist
from dhod.
This almost works, only one problem, the TFP implementation of the Lambert W function sometimes gets stuck in an infinite loop. I should look at the scipy implementation to figure out what the difference is, and how to avoid that loop
from dhod.
Hmm, I haven't noticed problems with this implementation, although I rewrote it myself so it's possible I wouldn't have. Do failures only happen for specific params?
from dhod.
apparently not related to specific parameters, I haven't done extensive testing, but it gets stuck pretty often when sampling like10^4 samples
from dhod.
and the code doesn't have a max number of iteration stopping criterion, so that doesnt seem safe ^^'
from dhod.
Stopping criteria? Are we talking about the rnfw function in this module? Where do stopping criteria come into this algorithm?
from dhod.
ahh no sorry, miscommunication I think. I'm saying the TensorFlow Probability implementation of the Lambert W function gets stuck from time to time. That function is implmented using an iterative solver, have a look here:
Line 134 in c4622c8
But they didn't include a max_iter or something like that, and apparently in practice it gets stuck from time to time in an infinite loop. I need to check the scipy implementation of lambertw
to see how they achieve a more robust implementation.
The numpy code seems to be working great
from dhod.
Ok, this has been super useful @all-contributors please add @aphearin for ideas
from dhod.
I've put up a pull request to add @aphearin! 🎉
from dhod.
This has been merged to master, it now has tests that compare the results to halotools.
from dhod.
Related Issues (16)
- RelaxedBernoulli samples not differentiable HOT 5
- Adding contributions HOT 7
- Remove heavy TF model from git history HOT 1
- Implement and sample from Zheng2007 HOT 2
- Improve the README
- Add caching to GitHub CI HOT 1
- Proper inference of HOD parameters HOT 1
- Optimize HOD parameters to fit power spectrum HOT 1
- Compute a CIC density field from galaxy catalog HOT 7
- Implement a differentiable correlation function
- Make all sampling functions batch capable HOT 4
- Adding missing contributors HOT 6
- New versions of TFP cause NaN gradients for RelaxedBernoulli near p=0 and p=1 HOT 3
- Set default values for Zheng07 params to halotools values HOT 1
- Why not sampling all the things? HMC sampling of each individual galaxy activation HOT 8
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 dhod.