-
Notifications
You must be signed in to change notification settings - Fork 30
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
Derived variables from data on the LHS of tilde #519
Comments
Maybe we can perform some activity analysis as in autodiff algorithms. These analyses would allow us to verify whether a variable, like |
@sunxd3 do you think the JuliaBUGS's For example, can we run the model once to compute all EDIT: another option is to make certain mild assumptions on LHS variables, e.g. their |
There are some concerns. I think checks like TuringLang/Turing.jl#2218 is good, as it eliminated the mutability issues: two stochastic variables shouldn't have the same name. Which means, saving mapping like That being said, a glaring problem, in my opinion, is the unreliableness of evaluating the RHS of @model function m(y)
x ~ Normal()
a = x == 0 ? y : x
a ~ Normal()
end which makes "running once and deciding if variable is observation" not reliable. Using the type information to determine if a variable can be a good idea. Still some issues, one is that some function will error with I think we can and maybe should incorporate more static analysis into Turing, but we would also need to communicate the result of the analysis well to the users. Start adding more functionality into |
Feel free to explore this further and see whether you can create a check to warn the user at least. |
On further thoughts, if we allow running the model once, collect all LHS variable names, then run the model again, and check whether these LHS variables are assigned elsewhere (except for constructors like
Would that work? |
Conceptually yes, but it may require us to modify the |
AFAIK there's no way we can get around this without some form of "abstract interpretation" or the like. IMO this is not a super-important feature to pursue as you can always just write @model function demo(y, sigma; v = f(y))
...
end What I do agree with is that it's an issue that users think this is possible, and it might be worth doing something to warn the user. But as @sunxd3 said, this is not possible without altering the |
I agree that we don't need a new transformed data feature, but we want to find a way to inform the user when a variable is incorrectly treated as a model parameter. Something like |
As I mentioned above, we can't do that without altering every AFAIK the only ways to do this without something like that, is to do some static analysis or symbolic tracing. |
I am now leaning towards depreciating implicit conditioning via the model constructor. For clarity,
For example, We can always check arguments of explicit conditioning to be LHS variables and throw an error if they are not. This way, users won't be able to condition on intermediate variables, so the issue herein won't apply anymore. |
The following model will ignore the fact
v
is a derived variable from data and treatv
as a random variable. This is a known limitation ofDynamicPPL
. I am opening this issue to track it and discuss ideas on how to fix/disallow it.The text was updated successfully, but these errors were encountered: