pyro-ppl/pyro

MCMC num_chains>1 does not work on Windows

开放

#2,315 创建于 2020年2月19日

 (9 条评论) (0 个反应) (0 位负责人)Python (981 个派生)batch import
bughelp wanted

仓库指标

星标
 (8,211 个星标)
PR 合并指标
 (平均合并 10天 19小时) (30 天内合并 1 个 PR)

描述

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!

贡献者指南