You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depreciate@submodel l ~ m in favour of l ~ to_submodel(m); rename generated_quantities to returned (#696)
* Added `@returned_quantities` macro
* Added `@returned_quantities` to the docs
* Fixed names of doctests for `@returned_quantities`
* Update src/submodel_macro.jl
Co-authored-by: Xianda Sun <[email protected]>
* Added `@prefix` macro which calls `prefix` with a `Val` argument to
make things easier to basic users
* Convert the result of `prefix_expr` in `@prefix` into a `Sybmol`
before wrapping in `Val`
* Export `prefix` and `@prefix`
* Updated docstring for `@returned_quantities`
* Fixed bug in `rand` for `Model` where it would duplicate the non-leaf
contexts in `model.context`
* Update src/contexts.jl
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Added `prefix` and `@prefix` to docs
* removed the prefix=... syntax for `@returned_quantities`
* added deprecation.jl + deprecated `generated_quantities` in favour of `returned_quantities`
* removed export of `prefix` and `generated_quantities` (the latter is
exported by the deprecation macro)
* updated `DynamicPPLMCMCChainsExt` to define `returned_quantities`
* updated docs
* Update docs/src/api.md
Co-authored-by: Hong Ge <[email protected]>
* improved docstring for `prefix` and `@prefix`
* added `@returned_quantities` macro taking two arguments + removed
`returned_quantities` from exported functions
* updated docs to reflect the new two-argument `@returned_quantities`
* added depwarn to `@submodel` macro
* fixed reference
* fixed reference to `@prefix` in `@returned_quantities` macro
* actually fixed doc references
* updated doctests for `@submodel` to include the depwarn + added
warning regarding deprecation of `@submodel`
* added `to_sampleable` and limited `~` handling for submodels
* added docs to `to_sampleable` + removed the unnecessary macro exports
that we no longer need
* updated more docstrings
* added testing of deprecation warning of `@submodel` + replaced some
usages in tests (though we don't support some of these so we cant' do
that yet)
* Update test/compiler.jl
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* renamed `returned_quantities` to `returned` as requested
* removed redundant `SampleableModelWrapper` in favour of
`ReturnedModelWrapper` + introduced `rand_like!!` to hide explicit
calls to `_evaluate!!`
* updated tests + docstrings + warnings to use `returned`
* updated docs
* formatting
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update src/model.jl
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix docs
* export `to_sampleable` and add to docs
* fixed typo in warning
* removed unnecessary import in docstring
* added docstring to `rand_like!!`
* fixed docstring for `returned(model)`
* improvements to docstrings thanks to @penelopesym
Co-authored-by: Penelope Yong <[email protected]>
* added abstract type `Distributional` and concrete type `Sampleable`,
in addition to method `to_submodel`
* replaced usages of `returned` with `to_submodel`
* formatting
* Update docs/src/api.md
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* removed export of `to_sampleable` since it currently has no purpose +
fixed docs for `returned`
* formatting
* updated docstring for `condition` and `fix` to not use `@submdoel`
* added `check_tilde_rhs` for `Sampleable`
* let the field of sampleable determine whether it works or not
* add automatic prefixing of submodels + remove support for dot-tilde
since this is ambigious in this case
* added automatic prefixing for sub-models involved in `~` statements
* updated depwarn for `@submodel` and tests
* formatting
* updated docstrings
* updated docs
* added more depwarns to the doctests to see if that helps (though I
don't understand why this is needed for Documenter.jl)
* forgot one
* replaced usage of `generated_quantities` with `returned`
* foxed docstring for `to_submodel`
* patch version bump
---------
Co-authored-by: Xianda Sun <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: Penelope Yong <[email protected]>
Copy file name to clipboardExpand all lines: docs/src/api.md
+30-8
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,6 @@ These statements are rewritten by `@model` as calls of [internal functions](@ref
14
14
@model
15
15
```
16
16
17
-
One can nest models and call another model inside the model function with [`@submodel`](@ref).
18
-
19
-
```@docs
20
-
@submodel
21
-
```
22
-
23
17
### Type
24
18
25
19
A [`Model`](@ref) can be created by calling the model function, as defined by [`@model`](@ref).
@@ -110,6 +104,34 @@ Similarly, we can [`unfix`](@ref) variables, i.e. return them to their original
110
104
unfix
111
105
```
112
106
107
+
## Models within models
108
+
109
+
One can include models and call another model inside the model function with `left ~ to_submodel(model)`.
110
+
111
+
```@docs
112
+
to_submodel
113
+
```
114
+
115
+
Note that a `[to_submodel](@ref)` is only sampleable; one cannot compute `logpdf` for its realizations.
116
+
117
+
In the past, one would instead embed sub-models using [`@submodel`](@ref), which has been deprecated since the introduction of [`to_submodel(model)`](@ref)
118
+
119
+
```@docs
120
+
@submodel
121
+
```
122
+
123
+
In the context of including models within models, it's also useful to prefix the variables in sub-models to avoid variable names clashing:
124
+
125
+
```@docs
126
+
prefix
127
+
```
128
+
129
+
Under the hood, [`to_submodel`](@ref) makes use of the following method to indicate that the model it's wrapping is a model over its return-values rather than something else
130
+
131
+
```@docs
132
+
returned(::Model)
133
+
```
134
+
113
135
## Utilities
114
136
115
137
It is possible to manually increase (or decrease) the accumulated log density from within a model function.
@@ -118,10 +140,10 @@ It is possible to manually increase (or decrease) the accumulated log density fr
118
140
@addlogprob!
119
141
```
120
142
121
-
Return values of the model function for a collection of samples can be obtained with [`generated_quantities`](@ref).
143
+
Return values of the model function for a collection of samples can be obtained with [`returned(model, chain)`](@ref).
122
144
123
145
```@docs
124
-
generated_quantities
146
+
returned(::DynamicPPL.Model, ::NamedTuple)
125
147
```
126
148
127
149
For a chain of samples, one can compute the pointwise log-likelihoods of each observed random variable with [`pointwise_loglikelihoods`](@ref). Similarly, the log-densities of the priors using
0 commit comments