From 38445bb525b67dbae2ddf11341a4c38e83e132b4 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Mon, 19 May 2025 18:11:45 +0100 Subject: [PATCH 1/3] Remove methods moved to DynamicPPL --- src/variational/advi.jl | 70 ----------------------------------------- 1 file changed, 70 deletions(-) diff --git a/src/variational/advi.jl b/src/variational/advi.jl index ec3e6552e3..3819109a09 100644 --- a/src/variational/advi.jl +++ b/src/variational/advi.jl @@ -1,73 +1,3 @@ -# TODO: Move to Bijectors.jl if we find further use for this. -""" - wrap_in_vec_reshape(f, in_size) - -Wraps a bijector `f` such that it operates on vectors of length `prod(in_size)` and produces -a vector of length `prod(Bijectors.output(f, in_size))`. -""" -function wrap_in_vec_reshape(f, in_size) - vec_in_length = prod(in_size) - reshape_inner = Bijectors.Reshape((vec_in_length,), in_size) - out_size = Bijectors.output_size(f, in_size) - vec_out_length = prod(out_size) - reshape_outer = Bijectors.Reshape(out_size, (vec_out_length,)) - return reshape_outer โˆ˜ f โˆ˜ reshape_inner -end - -""" - bijector(model::Model[, sym2ranges = Val(false)]) - -Returns a `Stacked <: Bijector` which maps from the support of the posterior to โ„แตˆ with `d` -denoting the dimensionality of the latent variables. -""" -function Bijectors.bijector( - model::DynamicPPL.Model, ::Val{sym2ranges}=Val(false); varinfo=DynamicPPL.VarInfo(model) -) where {sym2ranges} - num_params = sum([ - size(varinfo.metadata[sym].vals, 1) for sym in keys(varinfo.metadata) - ]) - - dists = vcat([varinfo.metadata[sym].dists for sym in keys(varinfo.metadata)]...) - - num_ranges = sum([ - length(varinfo.metadata[sym].ranges) for sym in keys(varinfo.metadata) - ]) - ranges = Vector{UnitRange{Int}}(undef, num_ranges) - idx = 0 - range_idx = 1 - - # ranges might be discontinuous => values are vectors of ranges rather than just ranges - sym_lookup = Dict{Symbol,Vector{UnitRange{Int}}}() - for sym in keys(varinfo.metadata) - sym_lookup[sym] = Vector{UnitRange{Int}}() - for r in varinfo.metadata[sym].ranges - ranges[range_idx] = idx .+ r - push!(sym_lookup[sym], ranges[range_idx]) - range_idx += 1 - end - - idx += varinfo.metadata[sym].ranges[end][end] - end - - bs = map(tuple(dists...)) do d - b = Bijectors.bijector(d) - if d isa Distributions.UnivariateDistribution - b - else - wrap_in_vec_reshape(b, size(d)) - end - end - - if sym2ranges - return ( - Bijectors.Stacked(bs, ranges), - (; collect(zip(keys(sym_lookup), values(sym_lookup)))...), - ) - else - return Bijectors.Stacked(bs, ranges) - end -end - """ meanfield([rng, ]model::Model) From b84cf0f84ca31cd104843db60b661605cde76c01 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Mon, 19 May 2025 18:12:06 +0100 Subject: [PATCH 2/3] Bump patch --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 82d32ed82f..acffce201e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Turing" uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0" -version = "0.38.0" +version = "0.38.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -62,7 +62,7 @@ Distributions = "0.25.77" DistributionsAD = "0.6" DocStringExtensions = "0.8, 0.9" DynamicHMC = "3.4" -DynamicPPL = "0.36" +DynamicPPL = "0.36.3" EllipticalSliceSampling = "0.5, 1, 2" ForwardDiff = "0.10.3" Libtask = "0.8.8" From 8eb80ffcb845e6fb2f50fa17c5910a685533b72d Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Mon, 19 May 2025 18:13:17 +0100 Subject: [PATCH 3/3] Fix changelog --- HISTORY.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index d3d7c839f1..42415d7efc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +# Release 0.38.1 + +The method `Bijectors.bijector(::DynamicPPL.Model)` was moved to DynamicPPL.jl. + # Release 0.38.0 ## DynamicPPL version