Hi all,
I am trying to use the SMC sampler for Approximate Bayesian Computation, so I started with the great example here.
However, in PyMC3 v. 2.9.3 (checked on both Linux and MacOS), I do the following (straight from the example, as far as I can tell):
import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
import arviz as az
data = np.random.normal(loc=0, scale=1, size=1000)
def normal_sim(a, b):
return np.sort(np.random.normal(a, b, 1000))
with pm.Model() as example:
a = pm.Normal('a', mu=0, sd=5)
b = pm.HalfNormal('b', sd=1)
s = pm.Simulator('s', normal_sim,observed=np.sort(data))
trace_example = pm.sample_smc(kernel="ABC", epsilon=0.1)
And I get the following error message:
Sample initial stage: ...
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-1fbce33887a0> in <module>
11 b = pm.HalfNormal('b', sd=1)
12 s = pm.Simulator('s', normal_sim,observed=np.sort(data))
---> 13 trace_example = pm.sample_smc(kernel="ABC", epsilon=0.1)
~/opt/anaconda3/envs/surrogate-modelling/lib/python3.8/site-packages/pymc3/smc/sample_smc.py in sample_smc(draws, kernel, n_steps, parallel, start, cores, tune_steps, p_acc_rate, threshold, epsilon, dist_func, sum_stat, progressbar, model, random_seed)
150 stage = 0
151 smc.initialize_population()
--> 152 smc.setup_kernel()
153 smc.initialize_logp()
154
~/opt/anaconda3/envs/surrogate-modelling/lib/python3.8/site-packages/pymc3/smc/smc.py in setup_kernel(self)
140 simulator.observations,
141 simulator.distribution.function,
--> 142 [v.name for v in simulator.distribution.params],
143 self.model,
144 self.var_info,
TypeError: 'NoneType' object is not iterable
Am I doing something incorrectly? My install works fine for standard PyMC sampling using NUTS. Many thanks!