-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add givens argument to DensityDist #4433
Conversation
One question. I usually use DensityDist as follows: def mydist(var1, var1):
self.var1 = var1
self.var2 = var2
def logp(value):
return value * self.var1 + self.var2**2
with pm.Model() as m:
norm = pm.Normal("norm", 0, 1)
halfnorm = pm.HalfNormal("halfnorm", 1)
like = pm.DensityDist("like", mydist(norm, halfnorm), observed=data) Is there a problem with this approach? It looks much more in line with how normal distributions are used. If it works, why not just force this way of using DensityDist (by checking observed is just data as you are doing but without the new argument)? Edit: Oh, I see this is designed to address the use of non theano functions. |
There already are checks in place (that I kept) to make sure that the variable passed as We considered forcing this way of using
For better or for worse, using DensityDist like this is a feature whose usage is encouraged by the official documentation. |
Thanks for the detailed answer. I would think a single standard would be better, but I understand there is some considerable baggage to this issue. Should we then have a brief notebook that shows the different compatible ways of using the DensityDist? I worry that for novices facing issues (me often included), having different ways of instantiating it makes it more difficult to pinpoint where the problems are coming from (e.g. is it a syntax issue or a model/statistical one?). |
Maybe add one example with the givens in the docstrings? |
Yes, that is the plan, especially since part of the original issue was with documentation using model parameters as
I completely understand that, it happens to me too, and especially if shapes are involved I think it happens to everyone. I have tried to be as explicit and vigilant as possible to catch issues early on and raise informative error messages, maybe there are even a couple extra ones that can be added. |
TIL: givens is the plural of given. I was going to ask why not just call it given. |
givens : dict, optional | ||
Model variables on which the DensityDist is conditioned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not include this in the arguments to __init__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that givens
(or given
if it's renamed) will never get to be passed to __init__
because it's popped from kwargs in __new__
, but truth be told, even after getting this to work I am not yet completely sure I understand new vs init. I have added it to the docstring anyways because of its special use tied to DensityDist and MultiObservedRV to make sure it's documented somewhere people searching for it can find it.
We can call it given, I have no preference whatsoever |
I am not a native English speaker, so that's probably why I was surprised. Just to be clear, I am not defending that it be (or not) changed. I just wrote it to save googling time if someone else happened to be as surprised as I was. |
I guess now it may be better to wait until after #4440, not sure about the timeline/versions |
This will take a while. I think we will soon make a patch release |
What is the released date we are aiming for with 3.11.1 roughly? |
We could get it done this week if we want to. The two PRs in the milestone are at the finish line and the issue is just optional. |
This PR touches APIs that are heavily refactored with |
That's a tough question, because—right now— Regardless, we can merge this and I can simply rebase the |
I don't really care if this gets merged or not (personally I would have already removed DensityDist), but I think that having this factory that you mention would be a great idea, people seem to love the Therefore, I think the best approach would be to at some point (not sure when) add a |
It "too late" for a future warning. Instead it sounds like the |
sounds good, I will close this PR then and the related ones |
Hi, I am new to pyMC3 and need to use a black box likelihood model as described here https://docs.pymc.io/notebooks/blackbox_external_likelihood.html. I stumbled above the arviz error message also described here https://stackoverflow.com/questions/62800160/theano-error-when-using-pymc3-theano-gof-fg-missinginputerror. Following this conversation, I am not sure if it is again possible to use an external likelihood or not? Best, Johannes |
@jduerholt should be - the backbox likelihood examples are getting updated in this PR: pymc-devs/pymc-examples#28 |
This closes #4002 and should finish with all the DensityDist issues and complains when trying to
pass
FreeRVs
to theobserved
kwarg. This was originally possible and at some point it broke dueto ArviZ trying to store the variables passed as
observed
in theobserved_data
group. This PRimplements @rpgoldman idea of "splitting" the original unintuitive
observed
argument intoobserved
(which must be data) andgivens
which can beFreeRVs
to maintain all the initialflexibility of
DensityDist
.The current proposal keeps the
data
attribute unchanged and adds agivens
attribute which ArviZcan use to filter all the
FreeRVs
indata
and avoid crashing.Note: To actually work, this PR also needs arviz-devs/arviz#1520
Checklist