The SVI tutorial (http://pyro.ai/examples/svi_part_i.html#A-simple-example) shows how to create two parameters specifically:
def guide(data): # register the two variational parameters with Pyro. alpha_q = pyro.param("alpha_q", torch.tensor(15.0), constraint=constraints.positive) beta_q = pyro.param("beta_q", torch.tensor(15.0), constraint=constraints.positive) # sample latent_fairness from the distribution Beta(alpha_q, beta_q) pyro.sample("latent_fairness", dist.Beta(alpha_q, beta_q))
How does one create a variable number of parameters? The tutorial (and its successors) doesn’t specify this very simple, common use case.
For instance, suppose I have N coins and I want to identify each coin’s probability of heads, with a Beta guide for each coin. I want 2N variational parameters for the N variational Beta distributions. How do I do this?