Multiple guides for same model

I’m trying to run multiple guides with different initialization (random) using a for loop. But it seems the initial value is same each time guide is called. How to I rectify this?

def guide():
       var_mu_1 = pyro.param('var_mu_1', torch.randn(1))
       var_mu_sig_1 = pyro.param('var_mu_sig_1', torch.tensor(1.),
                             constraint=constraints.positive)
       pyro.sample('mu_1', dist.Normal(loc=var_mu_1, scale=var_mu_sig_1))

I want torch.randn to have a different value each time I call guide in SVI

are you clearing the param store between using the different guides?

What’s your use case for running multiple guides? This will not work because param values have a global scope. The first time pyro.param('var_mu_1', ...) is called, it registers an initial value in the global parameter store keyed by the name ‘var_mu_1’. The next time this statement is called, it will simply return the value from the the param store (without re-initializing). As @jpchen suggested, you could just call pyro.clear_param_store() after training each guide and retrieving the results before starting to train another one in a loop.

Thanks guys. I’m working on Variational Inference with different initialization.