-
Notifications
You must be signed in to change notification settings - Fork 25
/
DynamicPPL.jl
174 lines (159 loc) · 3.37 KB
/
DynamicPPL.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
module DynamicPPL
using AbstractMCMC: AbstractSampler, AbstractChains
using AbstractPPL
using Bijectors
using Distributions
using OrderedCollections: OrderedDict
using AbstractMCMC: AbstractMCMC
using BangBang: BangBang, push!!, empty!!, setindex!!
using ChainRulesCore: ChainRulesCore
using MacroTools: MacroTools
using ConstructionBase: ConstructionBase
using Setfield: Setfield
using ZygoteRules: ZygoteRules
using LogDensityProblems: LogDensityProblems
using LinearAlgebra: Cholesky
using DocStringExtensions
using Random: Random
import Base:
Symbol,
==,
hash,
getindex,
setindex!,
push!,
show,
isempty,
empty!,
getproperty,
setproperty!,
keys,
haskey
# VarInfo
export AbstractVarInfo,
VarInfo,
UntypedVarInfo,
TypedVarInfo,
SimpleVarInfo,
push!!,
empty!!,
getlogp,
setlogp!!,
acclogp!!,
resetlogp!!,
get_num_produce,
set_num_produce!,
reset_num_produce!,
increment_num_produce!,
set_retained_vns_del_by_spl!,
is_flagged,
set_flag!,
unset_flag!,
setgid!,
updategid!,
setorder!,
istrans,
link!,
link!!,
invlink!,
invlink!!,
tonamedtuple,
values_as,
# VarName (reexport from AbstractPPL)
VarName,
inspace,
subsumes,
@varname,
# Compiler
@model,
# Utilities
vectorize,
reconstruct,
reconstruct!,
Sample,
init,
vectorize,
OrderedDict,
# Model
Model,
getmissings,
getargnames,
generated_quantities,
extract_priors,
# Samplers
Sampler,
SampleFromPrior,
SampleFromUniform,
# Contexts
SamplingContext,
DefaultContext,
LikelihoodContext,
PriorContext,
MiniBatchContext,
PrefixContext,
ConditionContext,
assume,
dot_assume,
observe,
dot_observe,
tilde_assume,
tilde_observe,
dot_tilde_assume,
dot_tilde_observe,
# Pseudo distributions
NamedDist,
NoDist,
# Prob macros
@prob_str,
@logprob_str,
# Convenience functions
logprior,
logjoint,
pointwise_loglikelihoods,
condition,
decondition,
fix,
unfix,
# Convenience macros
@addlogprob!,
@submodel
# Reexport
using Distributions: loglikelihood
export loglikelihood
# Used here and overloaded in Turing
function getspace end
"""
AbstractVarInfo
Abstract supertype for data structures that capture random variables when executing a
probabilistic model and accumulate log densities such as the log likelihood or the
log joint probability of the model.
See also: [`VarInfo`](@ref), [`SimpleVarInfo`](@ref).
"""
abstract type AbstractVarInfo <: AbstractModelTrace end
const LEGACY_WARNING = """
!!! warning
This method is considered legacy, and is likely to be deprecated in the future.
"""
# Necessary forward declarations
include("utils.jl")
include("selector.jl")
include("model.jl")
include("sampler.jl")
include("varname.jl")
include("distribution_wrappers.jl")
include("contexts.jl")
include("abstract_varinfo.jl")
include("threadsafe.jl")
include("varinfo.jl")
include("simple_varinfo.jl")
include("context_implementations.jl")
include("compiler.jl")
include("prob_macro.jl")
include("compat/ad.jl")
include("loglikelihoods.jl")
include("submodel_macro.jl")
include("test_utils.jl")
include("transforming.jl")
include("logdensityfunction.jl")
include("extract_priors.jl")
end # module