How can I set multivariate normal distribution on separated variables in guide?

Suppose I have two real parameters a and b to infer.
If I write

def guide(*args, **kwds):
    m1 = pyro.param("m1", torch.tensor(0.0))
    m2 = pyro.param("m2", torch.tensor(0.0))
    s1 = pyro.param("s1", torch.tensor(1.0), constraint=constraints.positive)
    s2 = pyro.param("s2", torch.tensor(1.0), constraint=constraints.positive)
    a = pyro.sample("a", dist.Normal(m1, s1))
    b = pyro.sample("b", dist.Normal(m2, s2))

it means I use mean-field approximation, q(a, b) = q(a)a(b).

Now how can I set multivariate Normal distribution on (a, b)? I know I can modify my entire model to use array w = [a, b] and set 2D Normal on w but I’d like to know if there is a way to do it on separated variables a and b.

I also know AutoMultivariateNormal guide can do this. So how can I do this manually?

doing it fully manually is a bit painful and not recommended; see the source code for AutoMultivariateNormal. if you want a custom guide, parts of which are multivariante normal, you can use AutoGuideList and supporting machinery to mix and match different AutoGuides

@martinjankowiak

Thank you for reply. I’ll check and try AutoGuideList.