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
[Merged by Bors] - DAG Model interface #47
Conversation
Pull Request Test Coverage Report for Build 1679328117Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Codecov Report
@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 77.06% 81.44% +4.37%
==========================================
Files 2 3 +1
Lines 109 194 +85
==========================================
+ Hits 84 158 +74
- Misses 25 36 +11
Continue to review full report at Codecov.
|
No substantive comments other than that this is cool! May do a review later when I get more time. |
I think all the necessary functions needed for dictionary-like iterations are now supported. There was a problem with the adjacency matrix function in that it didn't support nodes that had only one input. I've added a fix for this but it's not totally type stable so still working on it. |
@yebai I've merged |
@PavanChaggar thanks, let's still keep a dedicated |
Let's also rename |
I'd still like it to go into a separate submodule, so that it's clear that this is the part for one, concrete implementation. |
@@ -17,4 +16,10 @@ include("abstractmodeltrace.jl") | |||
include("abstractprobprog.jl") | |||
include("deprecations.jl") | |||
|
|||
# GraphInfo | |||
module GraphPPL |
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.
module GraphPPL | |
module GraphInfo |
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 don't think I'm allowed to call it GraphInfo
. Otherwise it prompts the following error:
ERROR: LoadError: LoadError: invalid redefinition of constant GraphInfo
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.
Looks great - many thanks @PavanChaggar! I left some minor comments above.
bors r+ |
This is a draft PR introducing a `Model` type that stores and makes use the model graph. The main type introduced here is the `Model` struct which stores the `ModelState` and `DAG`, each of which are their own types. `ModelState` contains information about the node values, dependencies and eval functions and `DAG` contains the graph and topologically ordered vertex list. A model can be constructed in the following way: ```julia julia> nt = ( s2 = (0.0, (), () -> InverseGamma(2.0,3.0), :Stochastic), μ = (1.0, (), () -> 1.0, :Logical), y = (0.0, (:μ, :s2), (μ, s2) -> MvNormal(μ, sqrt(s2)), :Stochastic) ) (s2 = (0.0, (), var"#33#36"(), :Stochastic), μ = (1.0, (), var"#34#37"(), :Logical), y = (0.0, (:μ, :s2), var"#35#38"(), :Stochastic)) julia> Model(nt) Nodes: μ = (value = 1.0, input = (), eval = var"#16#19"(), kind = :Logical) s2 = (value = 0.0, input = (), eval = var"#15#18"(), kind = :Stochastic) y = (value = 0.0, input = (:μ, :s2), eval = var"#17#20"(), kind = :Stochastic) DAG: 3×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries: ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0 1.0 ⋅ ``` At present, only functions needed for the constructors are implemented, as well as indexing using `@varname`. I still need to complete the integration with the AbstractPPL api. TODO: ~~- [ ] `condition`/`decondition`,~~ ~~- [ ] `sample`~~ ~~- [ ] `logdensityof`~~ - [x] pure functions for ordered dictionary, as outlined in [AbstractPPL](https://github.com/TuringLang/AbstractPPL.jl#property-interface) Feedback on `Model` structure welcome whilst I implement the remaining features!
Pull request successfully merged into main. Build succeeded: |
This is a draft PR introducing a
Model
type that stores and makes use the model graph.The main type introduced here is the
Model
struct which stores theModelState
andDAG
, each of which are their own types.ModelState
contains information about the node values, dependencies and eval functions andDAG
contains the graph and topologically ordered vertex list.A model can be constructed in the following way:
At present, only functions needed for the constructors are implemented, as well as indexing using
@varname
. I still need to complete the integration with the AbstractPPL api. TODO:- [ ]condition
/decondition
,- [ ]sample
- [ ]logdensityof
Feedback on
Model
structure welcome whilst I implement the remaining features!