Comments (6)
I prefer to keep our current api (for rvs/logdf/frozen) and just rewrite the init method so that it only initializes things we need (AFAIK, we only need the parse_args method to automatically parse args).
I think this is worth discussing and fleshing out a bit. I used scipy to begin with as it was the choice of least resistance, but I am not convinced that following any of the design patterns from scipy will be a good long term plan. :)
My thought is that there is little benefit in maintaining frozen / unfrozen distribution objects, and significant maintenance cost. A lot of the convoluted code that we have inherited stems precisely from having to maintain both of these patterns.
I am not sure about why the scipy devs decided to support this, but I have not come across any use case for the non-frozen distribution instances, and our inference algorithms don't use that either. There aren't any perf benefits worth mentioning as well since sampling time would typically outweigh any minor savings from not having to create class instances to begin with. The initial version of Pyro actually followed this scipy pattern of frozen / non-frozen distributions but we changed to using distribution classes due to the tech debt that this decision led to!
I am not sure if we would need parse_args
for the same reason. Instead, we could also just remove the loc, scale args from all the continuous distributions, and if users need to scale or translate their instances, using a TransformedDistribution
is probably a better design pattern. I think if we stick closer to torch.distributions
, we can just build off of the work that we know works well. If there are some deficiencies in the design of torch distributions, we shouldn't certainly overlook that and improve on it though.
from numpyro.
I think this will require quite a few changes, so I'll try to figure out a way to do this more gradually, maybe by prototyping this in a separate module that can later be swapped out if we are happy with the design. For now, let us continue to use what we have, but I would like to address this soon rather than add more layers on top of an already convoluted design.
from numpyro.
@fehiepsi - Let me know your thoughts. I think we should address this soon, so that we don't pile on more tech debt. I can take a look at it.
from numpyro.
I think to begin with we can start by only supporting sample, log_prob methods and adding more as we go along.
Agree. Currently, we only use rvs/logpdf for doing inference so there is no need to get inherited from scipy. I prefer to keep our current api (for rvs/logdf/frozen) and just rewrite the init method so that it only initializes things we need (AFAIK, we only need the parse_args
method to automatically parse args). Other infos such as momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, longname=None, extradoc=None, seed=None
are not necessary right now. We can add more functionalities from scipy or from our own usage later.
from numpyro.
Hmm... so your proposal is to not use the api of scipy.stats. I misunderstood it. That makes sense to me! The repo is numpyro, not scipyro, so we are free to design for our convenience. 👍 :D Pls go for it!
from numpyro.
Previously, I put more weights on scipy users (so they just write a model with their familiarity). But now, I think that using pytorch/pyro dist interface will make transitions from pyro and numpyro easier for users (we only need to change the import torch.distributions by numpyro.distributions) without having to modify the model. It also makes it easier to debug what is going wrong by comparing to a corresponding pyro inference. I think that this aligns with your ideas so please feel free to build what you intend to do.
from numpyro.
Related Issues (20)
- [FR] Truncated Power Law distribution
- An auto guide's `_unpack_latent` and `_unpack_latent._inverse` don't use produce the same order HOT 1
- [FR] Utility for joint distributions HOT 14
- How can I gibbs before HMC/NUTS? HOT 8
- Large potential energy while using `HMCGibbs` at the initial stage HOT 3
- Inference Test Failing HOT 2
- Figure in AR2 example is not reproducible
- Got Problems When Computing Log Likelihoods in a Scan-Based VAR Model HOT 2
- Inference for `gaussian_hmm` is broken on latest jax version (0.4.30) HOT 1
- autocorrelation function HOT 5
- saving render_model() output to the desired file path HOT 5
- Object oriented wrapper API HOT 5
- Stress test utility for numpyro? HOT 2
- Samples are outside the support for DiscreteUniform distribution HOT 3
- Crash when using `TruncatedNormal` in `parallel` MCMC, but not in `sequential` MCMC HOT 5
- `nuts.get_extra_fields()["num_steps"]=0` after warmup HOT 4
- Trouble Initializing Parameters with Highly Degenerate Data HOT 1
- Predictive: better docs for setting obs to `None` HOT 4
- Error in model using CircularReparam when trying to use Predictive HOT 1
- Error when using obs_mask and predictive with different input shape HOT 2
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 numpyro.