Skip to content

Conditioning does not work with NamedDist #371

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

Closed
bgroenks96 opened this issue Feb 13, 2022 · 1 comment
Closed

Conditioning does not work with NamedDist #371

bgroenks96 opened this issue Feb 13, 2022 · 1 comment

Comments

@bgroenks96
Copy link
Collaborator

It looks like condition breaks with variables declared via NamedDist:

@model function testmodel()
  x ~ NamedDist(Normal(0,1), :z)
  return x
end
conditioned_model = Turing.condition(testmodel(), z=1.0)
@assert conditioned_model()  1.0 # fails, since z is still sampled

Tested on Turing v.0.20.1

@yebai
Copy link
Member

yebai commented Mar 11, 2022

We won't need a special fix after #400

@yebai yebai closed this as completed Mar 11, 2022
bors bot pushed a commit that referenced this issue Jun 15, 2022
This PR adds a method called `resolve_varnames(varname, dist)` and adds an additional generated variable for each `~` which now holds the RHS of `~`. 

It does address #371 but uncertain if this is the best way, so wouldn't recommend merging this just yet. But putting it here so we can colab on it.

Co-authored-by: Hong Ge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants