You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having an issue with initialising a model with the init_by_median() strategy for my MCMC NUTS model.
I am drawing the location parameter of a VonMises distribution from a VonMises prior and I reparam this parameter with CircularReparam().
Working example:
import numpyro
from numpyro import sample, plate
from numpyro.infer import NUTS, MCMC, init_to_median
from numpyro.distributions import VonMises
from numpyro.handlers import reparam
from jax.random import PRNGKey
import jax.numpy as jnp
@numpyro.handlers.reparam(
config={"loc_1": numpyro.infer.reparam.CircularReparam()}
)
def tst(x):
loc_1 = sample("loc_1", VonMises(0, 100))
conc = 2
with plate("plate", len(x)):
y = sample("y", VonMises(loc_1, conc), obs=x)
return loc_1
if __name__ == "__main__":
kernel = NUTS(tst, init_strategy=init_to_median(num_samples=1000))
mcmc = MCMC(kernel, num_warmup=1, num_samples=10)
mcmc.warmup(PRNGKey(42), collect_warmup=True, x=jnp.array([1, 2, 3]))
print(mcmc.get_samples())
Hi!
I am having an issue with initialising a model with the init_by_median() strategy for my MCMC NUTS model.
I am drawing the location parameter of a VonMises distribution from a VonMises prior and I reparam this parameter with CircularReparam().
Working example:
Output:
This should be the median of VonMises(0, 100), which is 0. If you remove the reparameterisation, you get exactly this value.
The text was updated successfully, but these errors were encountered: