-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Lines 1134 to 1146 in 08fffa2
| function returned(model::Model, parameters::Union{NamedTuple,AbstractDict{<:VarName}}) | |
| vi = DynamicPPL.setaccs!!(VarInfo(), ()) | |
| # Note: we can't use `fix(model, parameters)` because | |
| # https://github.com/TuringLang/DynamicPPL.jl/issues/1097 | |
| # Use `nothing` as the fallback to ensure that any missing parameters cause an error | |
| ctx = InitContext(Random.default_rng(), InitFromParams(parameters, nothing)) | |
| new_model = setleafcontext(model, ctx) | |
| # We can't use new_model() because that overwrites it with an InitContext of its own. | |
| return first(evaluate!!(new_model, vi)) | |
| end | |
| Base.@deprecate returned(model::Model, values, keys) returned( | |
| model, NamedTuple{keys}(values) | |
| ) |
#1096 implemented returned(::Model, ::AbstractDict). But, since we probably want to extend InitFromParams to accept multiple different inputs, we should actually generalise this to returned(::Model, x) for any x that InitFromParams supports.
For example, since TuringLang/Turing.jl#2710 implements InitFromParams(::ModeResult), doing this would automatically fix TuringLang/Turing.jl#2607.
Metadata
Metadata
Assignees
Labels
No labels