Skip to content

Implement to_vec_transform for ProductNamedTupleDistribution #1077

@penelopeysm

Description

@penelopeysm

I think along with TuringLang/Bijectors.jl#418 this is all that's needed to get Turing to sample ProductNamedTupleDistribution. Oh, also some output_size(f, sz) need to be changed to output_size(f, dist) instead.

Note that unpacking syntax on the LHS of tilde will still not be allowed. Thus

@model function f()
    x ~ product_distribution((a = Normal(), b = LogNormal()))
    y ~ Normal(x.a, x.b)
end

is OK, but this is not

@model function f()
    (; a, b) ~ product_distribution((a = Normal(), b = LogNormal()))
    y ~ Normal(a, b)
end

Making the latter work will require changes to the compiler. In any case people can always do

@model function f()
    x ~ product_distribution((a = Normal(), b = LogNormal()))
    (; a, b) = x
    y ~ Normal(a, b)
end

so I don't see this as much of a loss.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions