pyro-ppl/pyro

MCMC num_chains>1 does not work on Windows

Aperta

#2315 aperta il 19 feb 2020

 (9 commenti) (0 reazioni) (0 assegnatari)Python (981 fork)batch import
bughelp wanted

Metriche repository

Star
 (8211 stelle)
Metriche merge PR
 (Merge medio 10g 19h) (1 PR mergiata in 30 g)

Descrizione

Hi!

I tried to implement some very simple Bayesian Regression via NUTS/MCMC. It works well, if I use a single Markov Chain, however, when I increase the number, the program does not stop anymore (but also doesn't yield any error message).

import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc import MCMC, NUTS

X = torch.FloatTensor([[float(i), 1.] for i in range(100)]).reshape(-1, 2)
y = torch.FloatTensor([float(i) for i in range(100)])

def linreg(x, y):
    w = pyro.sample('w', dist.Normal(torch.zeros(x.size(1))+5., 10.0))
    return pyro.sample('measurement', dist.Normal(x@w, 1.), obs=y)

hmc_kernel = NUTS(linreg)
posterior = MCMC(hmc_kernel, num_samples=10, warmup_steps=10, num_chains=2)
posterior.run(X, y)

If you set num_chains to 1, it will work.

Pyro 1.2.1 PyTorch 1.4.0+cpu Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] Windows 10

Thanks for help!

Guida contributor