我是pymc3的新手,正在尝试编写代码以对MCMC进行简单的贝叶斯推理。但是下午。样本只是不断给我错误:
BrokenPipeError:[Errno 32]管道损坏
count_data = np.loadtxt('txtdata.csv')
n_count_data = len(count_data)
alpha = 1/count_data.mean()
with pm.Model() as model:
lamda_1 = pm.Exponential("lamda_1", alpha)
lamda_2 = pm.Exponential("lamda_2", alpha)
tau = pm.DiscreteUniform("tau",lower = 0, upper = n_count_data)
print ("Random Output : ", tau.random(), tau.random(), tau.random())
def lamda_(tau = tau, lamda_1 = lamda_1, lamda_2 = lamda_2):
init_zero = tt.as_tensor_variable(np.zeros(n_count_data))
out = pm.Deterministic("out", init_zero)
out = tt.set_subtensor(out[:tau], lamda_1)
out = tt.set_subtensor(out[tau:], lamda_1)
return out
lamda_val = lamda_(tau, lamda_1, lamda_2)
observation = pm.Poisson("obs", lamda_val, observed = count_data)
model = pm.Model([observation, lamda_1, lamda_2, tau])
trace = pm.sample(40000)
任何人都可以帮助查看导致问题的原因吗?谢谢。