Skip to content

Conversation

@devmotion
Copy link
Member

As can be seen in #50 (comment), the output of model() can be quite surprising if no return statements are specified in the model definition. One possible solution to the problem that is implemented in this PR is to always return nothing as a fallback. An alternative would be to return the VarInfo object as a fallback but that might be not completely user-friendly since it might not be clear how to handle or analyse it.

Additionally, currently logp is reset both in the default evaluation function and in runmodel!, so basically model(vi) and runmodel!(vi) are doing the same thing currently apart from adjusting eval_num. I removed the resetlogp! statement in the evaluation function to allow for greater flexibility and removed the runmodel! function. Instead now one can call model() and model(vi) - without vi a new VarInfo object is created but otherwise they are doing exactly the same thing.

@codecov
Copy link

codecov bot commented Apr 9, 2020

Codecov Report

Merging #63 into master will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
- Coverage   79.47%   79.42%   -0.05%     
==========================================
  Files          13       13              
  Lines         843      841       -2     
==========================================
- Hits          670      668       -2     
  Misses        173      173              
Impacted Files Coverage Δ
src/DynamicPPL.jl 100.00% <ø> (ø)
src/compiler.jl 89.26% <100.00%> (-0.08%) ⬇️
src/model.jl 77.77% <100.00%> (-1.17%) ⬇️
src/varinfo.jl 88.27% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c071df...18a0353. Read the comment docs.

@phipsgabler
Copy link
Member

phipsgabler commented Apr 9, 2020

I, as a quite innocent user, would expect a model to behave like a function, and to return the value of the last line, with a tilde having the same semantics as an assignment.

nothing or VarInfo as automatic results unless there's a return is really counterintuitive, IMHO (nothing less so, but still).

So the easiest thing would be to define the semantics of tildes to be equivalent to = and .=, and just add the observed or sampled value to the generated code, after the accumulation of log-probabilities.

@devmotion
Copy link
Member Author

Ah, yes I guess that's even better! Yeah the main motivation for nothing was to avoid the log probabilities but I wasn't completely satisfied with the solution in this PR 😄

Copy link
Member

@phipsgabler phipsgabler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautyful.

@yebai
Copy link
Member

yebai commented Apr 10, 2020

I resolved some merge conflicts. It seems some tests are still broken.

@devmotion
Copy link
Member Author

I removed two runmodel! imports that were reintroduced when merging master, let's see if the tests pass now.

@devmotion
Copy link
Member Author

OK, now only code coverage fails.

Copy link
Contributor

@mohamed82008 mohamed82008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@yebai yebai merged commit 9fbe09a into master Apr 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the model branch April 10, 2020 11:42
@yebai
Copy link
Member

yebai commented Apr 10, 2020

thanks @devmotion!

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

Successfully merging this pull request may close these issues.

5 participants