Hi all,
I had a model that worked fine, but I had to format my computer and reinstall all of the packages (newest versions), after that my model stopped working, showing the follow error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)
883 outputs =\
--> 884 self.fn() if output_subset is None else\
885 self.fn(output_subset=output_subset)
TypeError: expected type_num 1 (NPY_INT8) got 7
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-44-1f027805cff2> in <module>()
2 # trace = pm.backends.text.load('trace')
3 # db = pm.backends.Text('trace')
----> 4 trace = pm.sample(5e2, njobs=2, progressbar=True)
5 # trace = pm.sample(5e4, njobs=2, step=[pm.HamiltonianMC(scaling=trace[-1]), pm.NUTS(scaling=trace[-1])], start=trace[-1], tune=1000, progressbar=True, trace=db)
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, progressbar, model, random_seed)
151 start = start_
152 else:
--> 153 step = assign_step_methods(model, step)
154
155 if njobs is None:
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in assign_step_methods(model, step, methods)
74
75 # Instantiate all selected step methods
---> 76 steps += [step(vars=selected_steps[step]) for step in selected_steps if selected_steps[step]]
77
78 if len(steps) == 1:
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in <listcomp>(.0)
74
75 # Instantiate all selected step methods
---> 76 steps += [step(vars=selected_steps[step]) for step in selected_steps if selected_steps[step]]
77
78 if len(steps) == 1:
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/nuts.py in __init__(self, vars, scaling, step_scale, is_cov, state, Emax, target_accept, gamma, k, t0, model, profile, **kwargs)
70 if isinstance(scaling, dict):
71 scaling = guess_scaling(
---> 72 Point(scaling, model=model), model=model, vars=vars)
73
74 n = scaling.shape[0]
/usr/local/lib/python3.5/dist-packages/pymc3/tuning/scaling.py in guess_scaling(point, vars, model, scaling_bound)
109 model = modelcontext(model)
110 try:
--> 111 h = find_hessian_diag(point, vars, model=model)
112 except NotImplementedError:
113 h = fixed_hessian(point, vars, model=model)
/usr/local/lib/python3.5/dist-packages/pymc3/tuning/scaling.py in find_hessian_diag(point, vars, model)
103 model = modelcontext(model)
104 H = model.fastfn(hessian_diag(model.logpt, vars))
--> 105 return H(Point(point, model=model))
106
107
/usr/local/lib/python3.5/dist-packages/pymc3/model.py in __call__(self, state)
465
466 def __call__(self, state):
--> 467 return self.f(**state)
468
469
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)
896 node=self.fn.nodes[self.fn.position_of_error],
897 thunk=thunk,
--> 898 storage_map=getattr(self.fn, 'storage_map', None))
899 else:
900 # old-style linkers raise their own exceptions
/usr/local/lib/python3.5/dist-packages/theano/gof/link.py in raise_with_op(node, thunk, exc_info, storage_map)
323 # extra long error message in that case.
324 pass
--> 325 reraise(exc_type, exc_value, exc_trace)
326
327
/usr/lib/python3/dist-packages/six.py in reraise(tp, value, tb)
683 value = tp()
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
686 raise value
687
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)
882 try:
883 outputs =\
--> 884 self.fn() if output_subset is None else\
885 self.fn(output_subset=output_subset)
886 except Exception:
TypeError: expected type_num 1 (NPY_INT8) got 7
Apply node that caused the error: Elemwise{Composite{(Switch(i0, (i1 - (i2 * i3)), i4) + log(i5))}}(Elemwise{Composite{Identity(GT(i0, i1))}}.0, TensorConstant{-0.6931471824645996}, TensorConstant{0.5}, Elemwise{exp,no_inplace}.0, TensorConstant{-inf}, Elemwise{Abs}[(0, 0)].0)
Toposort index: 112
Inputs types: [TensorType(int8, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(float32, scalar), TensorType(float64, scalar)]
Inputs shapes: [(), (), (), (), (), ()]
Inputs strides: [(), (), (), (), (), ()]
Inputs values: [array(1), array(-0.6931471824645996), array(0.5), array(1.3862943584215575), array(-inf, dtype=float32), array(1.3862943584215575)]
Outputs clients: [[for{cpu,scan_fn&scan_fn&scan_fn&scan_fn&scan_fn&scan_fn&scan_fn}(TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, TensorConstant{1}, Y012345601, Yp012345601, Elemwise{sub,no_inplace}.0, Elemwise{exp,no_inplace}.0, MakeVector{dtype='int64'}.0, Elemwise{exp,no_inplace}.0, Elemwise{exp,no_inplace}.0, Elemwise{exp,no_inplace}.0, Elemwise{exp}.0, Elemwise{eq,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{log,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{Composite{exp((-i0))}}.0, Elemwise{Composite{exp((-i0))}}.0, Elemwise{add,no_inplace}.0, gammaln.0, Elemwise{Composite{scalar_gammaln((i0 + i1))}}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{Identity(GT(i0, i1))}}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{(i0 + (scalar_sigmoid(i1) * i2))}}.0, Elemwise{Composite{((i0 - i1) - scalar_gammaln((i2 - i3)))}}.0, Elemwise{Composite{Identity(LE(i0, i1))}}.0, sigmoid.0, Elemwise{Composite{(scalar_sigmoid(i0) * i1)}}.0, Elemwise{sqr,no_inplace}.0, Elemwise{log,no_inplace}.0, Elemwise{log,no_inplace}.0, Elemwise{Composite{(scalar_sigmoid(i0) * scalar_sigmoid(i0) * i1)}}.0, Elemwise{Composite{(Switch(i0, (i1 - (i2 * i3)), i4) + log(i5))}}.0, Elemwise{Composite{(Switch(i0, (i1 - (i2 * i3)), i4) + log(i5))}}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{(Switch(Identity((i0 * LE(i1, i2))), i3, i4) + i5)}}[(0, 5)].0, Sum{acc_dtype=float64}.0, Elemwise{Composite{(Switch(Identity((GE(i0, i1) * LE(i0, i2))), i3, i4) + log(i5))}}.0, Elemwise{Composite{Identity(GT(i0, i1))}}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{Identity(GT(i0, i1))}}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0, Elemwise{exp,no_inplace}.0, Elemwise{add,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{(scalar_sigmoid(i0) * scalar_sigmoid(i0) * i1)}}.0, Elemwise{Abs}[(0, 0)].0, Elemwise{sgn}.0, Elemwise{sqr,no_inplace}.0), for{cpu,scan_fn&scan_fn}(Shape_i{0}.0, Subtensor{int64:int64:int8}.0, Shape_i{0}.0, Shape_i{0}.0, Y012345601, Yp012345601, Elemwise{exp,no_inplace}.0, MakeVector{dtype='int64'}.0, Elemwise{exp,no_inplace}.0, Elemwise{sub,no_inplace}.0, Elemwise{exp,no_inplace}.0, Elemwise{exp,no_inplace}.0, Elemwise{Exp}[(0, 0)].0, Elemwise{eq,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{log,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{Composite{exp((-i0))}}.0, Elemwise{Composite{exp((-i0))}}.0, Elemwise{add,no_inplace}.0, gammaln.0, Elemwise{Composite{scalar_gammaln((i0 + i1))}}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{Identity(GE(i0, i1))}}.0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{Identity(GT(i0, i1))}}.0, Elemwise{sqr,no_inplace}.0, Elemwise{Composite{(scalar_sigmoid(i0) * i1)}}.0, Elemwise{Composite{((i0 - i1) - scalar_gammaln((i2 - i3)))}}.0, Elemwise{Composite{Identity(LE(i0, i1))}}.0, sigmoid.0, Elemwise{Composite{(i0 + (scalar_sigmoid(i1) * i2))}}.0, Elemwise{sqr,no_inplace}.0, Alloc.0, Alloc.0, Alloc.0, Elemwise{log,no_inplace}.0, Elemwise{log,no_inplace}.0, Elemwise{Composite{(scalar_sigmoid(i0) * scalar_sigmoid(i0) * i1)}}.0, Elemwise{Composite{(Switch(i0, (i1 - (i2 * i3)), i4) + log(i5))}}.0, Elemwise{Composite{(Switch(i0, (i1 - (i2 * i3)), i4) + log(i5))}}.0, MakeVector{dtype='int64'}.0, Elemwise{Composite{((i0 * Abs(i1)) / sqr(Abs(i2)))}}.0, Elemwise{Composite{sgn((scalar_sigmoid(i0) * scalar_sigmoid(i1) * i2))}}.0, Elemwise{Composite{Abs(((i0 * i1 * i1) / (i2 * i2 * i2 * i2)))}}.0, Elemwise{Composite{(Switch(Identity((GE(i0, i1) * LE(i0, i2))), i3, i4) + log(i5))}}.0, Sum{acc_dtype=float64}.0, Elemwise{Composite{(Switch(Identity((GE(i0, i1) * LE(i0, i2))), i3, i4) + log(i5))}}.0, Elemwise{Composite{(Switch(Identity((i0 * LE(i1, i2))), i3, i4) + i5)}}[(0, 5)].0, Elemwise{sqr,no_inplace}.0, Elemwise{sqr,no_inplace}.0)]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
Thank you all!
Theano seems to be complaining because for some reason one of the inputs to a function is a float32 instead of a float64. You should use either single or double precision floats, but try not to mix them. Without the full code it is difficult to see where exactly this is happening.
Also, it looks like it is trying to initialize a chain using the MAP, which doesn't typically work nearly as good as advi. Could you update to the current release candidate and check if the error is fixed (we also use advi by default now).
@aseyboldt, I'm not using MAP, and I don't think the issue is the input type, I will paste the model:
with pm.Model() as zika_model:
pp = pm.Uniform("pp", lower=pp_mean/3, upper=(5/3)*pp_mean)
upper_beta = pm.Exponential("upper_beta", lam=1/2)
beta = pm.Uniform("beta", lower=0.5, upper=upper_beta, testval = 0.6)
beta_gamma = pm.Exponential("beta_gamma", lam=60)
alpha_gamma_mean = pm.Deterministic("alpha_gamma_mean", var=beta_gamma/7)
alpha_gamma = pm.Exponential("alpha_gamma", lam=alpha_gamma_mean)
gamma = pm.Gamma("gamma", alpha=alpha_gamma, beta=beta_gamma, testval=1/7)
I = pm.Uniform("I", lower=0, upper=fem_cases.sum(), shape=len(fem_cases))
R = pm.Deterministic("R", gamma*I)
S = pm.Uniform("S", lower=0, upper=N-(I+R), shape=len(fem_cases))
inc = pm.Deterministic("inc", beta*I*(S)/(S+I+R)-R)
po = pm.Uniform("po", lower=0, upper=1)
Y = pm.Poisson('Y', mu=inc, shape=len(fem_cases))
mu_Yo = pm.Deterministic("mu_Yo", var=Y*po)
Yp = pm.Poisson("Yp", mu=Y*pp, shape=len(fem_cases))
with zika_model:
Yo = pm.Poisson('Yo', mu=mu_Yo, observed=fem_cases)
mz = pm.Beta("mz", alpha=1, beta=1, observed=mz_freq)
M = pm.Binomial("M", n=Yp, p=mz, observed=loss_shifted40)
with zika_model:
trace = pm.sample(5e3, njobs=2, progressbar=True)
Which version of pymc are you using? The backtrace shows it is computing the hessian, which it shouldn't do on the release candidate.
edit: sorry, I just saw the discrete variables in there. That means that advi initialization won't work. Can you also add a (maybe generated) dataset? Then I could execute this myself, which makes debugging much easier.
@aseyboldt, pymc3 3.0, theano 0.9
Could you update to master? We are about to release a new version, and there were so many changes since 3.0 that it doesn't really make sense to try to find out what is happening there.
pip install git+https://github.com/pymc-devs/pymc3
@aseyboldt Did it, but now I got a issue in another model used before that one:
---------------------------------------------------------------------------
RemoteTraceback Traceback (most recent call last)
RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in __call__
self.fn() if output_subset is None else\
TypeError: expected type_num 1 (NPY_INT8) got 7
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/joblib/_parallel_backends.py", line 350, in __call__
return self.func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/joblib/parallel.py", line 131, in __call__
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/usr/local/lib/python3.5/dist-packages/joblib/parallel.py", line 131, in <listcomp>
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 291, in _sample
for it, strace in enumerate(sampling):
File "/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py", line 862, in __iter__
for obj in iterable:
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 389, in _iter_sample
point, states = step.step(point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py", line 24, in step
point, state = method.step(point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py", line 152, in step
apoint, stats = self.astep(bij.map(point))
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py", line 189, in astep
diverging, turning = tree.extend(direction)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py", line 288, in extend
self.left, self.depth, floatX(np.asarray(-self.step_size)))
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py", line 349, in _build_subtree
return self._single_step(left, epsilon)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py", line 314, in _single_step
right = self.leapfrog(left.q, left.p, left.q_grad, epsilon)
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 898, in __call__
storage_map=getattr(self.fn, 'storage_map', None))
File "/usr/local/lib/python3.5/dist-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/usr/lib/python3/dist-packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in __call__
self.fn() if output_subset is None else\
TypeError: expected type_num 1 (NPY_INT8) got 7
Apply node that caused the error: Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)](TensorConstant{1.0}, Elemwise{Composite{Identity(GT(i0, i1))}}.0, TensorConstant{-0.0032723..4201266718}, Elemwise{exp,no_inplace}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0)
Toposort index: 53
Inputs types: [TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar)]
Inputs shapes: [(), (), (), (), (), ()]
Inputs strides: [(), (), (), (), (), ()]
Inputs values: [array(1.0), array(1), array(-0.0032723434201266718), array(4.6014303593244465e+141), array(0, dtype=int8), array(-45.0)]
Outputs clients: [[Reshape{1}(Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)].0, TensorConstant{(1,) of -1})]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.5/dist-packages/joblib/_parallel_backends.py", line 359, in __call__
raise TransportableException(text, e_type)
joblib.my_exceptions.TransportableException: TransportableException
___________________________________________________________________________
TypeError Wed Jun 21 10:46:23 2017
PID: 4383 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=4000, step=[<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], start=None, trace=None, chain=0, tune=2000, progressbar=True, model=<pymc3.model.Model object>, random_seed=2070153010, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/4000 [00:00<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/4000 [00:00<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=4000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}, trace=None, chain=0, tune=2000, model=<pymc3.model.Model object>, random_seed=2070153010)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
state = [{'accept': 1.0, 'tune': True}]
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([ 5.35573599, 5.35573599]))
184 start = Edge(q0, p0, v0, self.dlogp(q0), start_energy)
185 tree = _Tree(len(p0), self.leapfrog, start, step_size, self.Emax)
186
187 for _ in range(self.max_treedepth):
188 direction = logbern(np.log(0.5)) * 2 - 1
--> 189 diverging, turning = tree.extend(direction)
diverging = undefined
turning = undefined
tree.extend = <bound method _Tree.extend of <pymc3.step_methods.hmc.nuts._Tree object>>
direction = -1
190 q = tree.proposal.q
191
192 if diverging or turning:
193 if diverging:
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in extend(self=<pymc3.step_methods.hmc.nuts._Tree object>, direction=-1)
283 tree, diverging, turning = self._build_subtree(
284 self.right, self.depth, floatX(np.asarray(self.step_size)))
285 self.right = tree.right
286 else:
287 tree, diverging, turning = self._build_subtree(
--> 288 self.left, self.depth, floatX(np.asarray(-self.step_size)))
self.left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
self.depth = 0
self.step_size = 0.18995892141289814
289 self.left = tree.right
290
291 self.depth += 1
292 self.accept_sum += tree.accept_sum
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _build_subtree(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), depth=0, epsilon=array(-0.18995892141289814))
344 tree = Subtree(None, None, None, None, -np.inf, 0, 1)
345 return tree, (error_msg, error, left), False
346
347 def _build_subtree(self, left, depth, epsilon):
348 if depth == 0:
--> 349 return self._single_step(left, epsilon)
self._single_step = <bound method _Tree._single_step of <pymc3.step_methods.hmc.nuts._Tree object>>
left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
epsilon = array(-0.18995892141289814)
350
351 tree1, diverging, turning = self._build_subtree(left, depth - 1, epsilon)
352 if diverging or turning:
353 return tree1, diverging, turning
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _single_step(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), epsilon=array(-0.18995892141289814))
309 return diverging, turning
310
311 def _single_step(self, left, epsilon):
312 """Perform a leapfrog step and handle error cases."""
313 try:
--> 314 right = self.leapfrog(left.q, left.p, left.q_grad, epsilon)
right = undefined
self.leapfrog = <theano.compile.function_module.Function object>
left.q = array([ 5.35573599, 5.35573599])
left.p = array([-0.29184532, -0.39283626])
left.q_grad = array([ 17779.4151146 , -9058.04433461])
epsilon = array(-0.18995892141289814)
315 except linalg.LinAlgError as err:
316 error_msg = "LinAlgError during leapfrog step."
317 error = err
318 except ValueError as err:
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
893 if hasattr(self.fn, 'thunks'):
894 thunk = self.fn.thunks[self.fn.position_of_error]
895 gof.link.raise_with_op(
896 node=self.fn.nodes[self.fn.position_of_error],
897 thunk=thunk,
--> 898 storage_map=getattr(self.fn, 'storage_map', None))
self.fn = <theano.gof.vm.CVM object>
899 else:
900 # old-style linkers raise their own exceptions
901 raise
902
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/gof/link.py in raise_with_op(node=Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i...}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0), thunk=<function Op.make_c_thunk.<locals>.rval>, exc_info=(<class 'TypeError'>, TypeError('expected type_num 1 (NPY_INT8) got 7',), <traceback object>), storage_map={TensorConstant{-0.0032723..4201266718}: [array(-0.0032723434201266718)], Reshape{1}.0: [None], Elemwise{Composite{Switch(GE(i0, (Composite{Swit...GE(i0, i1), i1, i0)}(i0, i1))}(i1, i2, i3))))}}.0: [None], Elemwise{eq,no_inplace}.0: [array([False, False, False, False, False, False,..., False,
False, False, False], dtype=bool)], lambda_1: [None], Elemwise{Composite{Identity(GT(i0, i1))}}.0: [array(1)], epsilon: [array(-0.18995892141289814)], Elemwise{Composite{(i0 + (i1 * i2 * i3))}}.0: [None], InplaceDimShuffle{x}.0: [array([-0.18995892])], Elemwise{exp}.0: [array(2.415049280601321e-69)], ...})
320 print("WARNING: %s error does not allow us to add extra error message" %
321 str(exc_type))
322 # Some exception need extra parameter in inputs. So forget the
323 # extra long error message in that case.
324 pass
--> 325 reraise(exc_type, exc_value, exc_trace)
exc_type = <class 'TypeError'>
exc_value = TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",)
exc_trace = <traceback object>
326
327
328 class Linker(object):
329 """
...........................................................................
/usr/lib/python3/dist-packages/six.py in reraise(tp=<class 'TypeError'>, value=TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",), tb=<traceback object>)
680
681 def reraise(tp, value, tb=None):
682 if value is None:
683 value = tp()
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
value.with_traceback = <built-in method with_traceback of TypeError object>
tb = <traceback object>
686 raise value
687
688 else:
689 def exec_(_code_, _globs_=None, _locs_=None):
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
879
880 # Do the actual work
881 t0_fn = time.time()
882 try:
883 outputs =\
--> 884 self.fn() if output_subset is None else\
self.fn = <theano.gof.vm.CVM object>
output_subset = None
885 self.fn(output_subset=output_subset)
886 except Exception:
887 restore_defaults()
888 if hasattr(self.fn, 'position_of_error'):
TypeError: expected type_num 1 (NPY_INT8) got 7
Apply node that caused the error: Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)](TensorConstant{1.0}, Elemwise{Composite{Identity(GT(i0, i1))}}.0, TensorConstant{-0.0032723..4201266718}, Elemwise{exp,no_inplace}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0)
Toposort index: 53
Inputs types: [TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar)]
Inputs shapes: [(), (), (), (), (), ()]
Inputs strides: [(), (), (), (), (), ()]
Inputs values: [array(1.0), array(1), array(-0.0032723434201266718), array(4.6014303593244465e+141), array(0, dtype=int8), array(-45.0)]
Outputs clients: [[Reshape{1}(Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)].0, TensorConstant{(1,) of -1})]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
___________________________________________________________________________
"""
The above exception was the direct cause of the following exception:
TransportableException Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in retrieve(self)
698 if getattr(self._backend, 'supports_timeout', False):
--> 699 self._output.extend(job.get(timeout=self.timeout))
700 else:
/usr/lib/python3.5/multiprocessing/pool.py in get(self, timeout)
607 else:
--> 608 raise self._value
609
TransportableException: TransportableException
___________________________________________________________________________
TypeError Wed Jun 21 10:46:23 2017
PID: 4383 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=4000, step=[<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], start=None, trace=None, chain=0, tune=2000, progressbar=True, model=<pymc3.model.Model object>, random_seed=2070153010, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/4000 [00:00<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/4000 [00:00<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=4000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}, trace=None, chain=0, tune=2000, model=<pymc3.model.Model object>, random_seed=2070153010)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
state = [{'accept': 1.0, 'tune': True}]
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([ 5.35573599, 5.35573599]))
184 start = Edge(q0, p0, v0, self.dlogp(q0), start_energy)
185 tree = _Tree(len(p0), self.leapfrog, start, step_size, self.Emax)
186
187 for _ in range(self.max_treedepth):
188 direction = logbern(np.log(0.5)) * 2 - 1
--> 189 diverging, turning = tree.extend(direction)
diverging = undefined
turning = undefined
tree.extend = <bound method _Tree.extend of <pymc3.step_methods.hmc.nuts._Tree object>>
direction = -1
190 q = tree.proposal.q
191
192 if diverging or turning:
193 if diverging:
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in extend(self=<pymc3.step_methods.hmc.nuts._Tree object>, direction=-1)
283 tree, diverging, turning = self._build_subtree(
284 self.right, self.depth, floatX(np.asarray(self.step_size)))
285 self.right = tree.right
286 else:
287 tree, diverging, turning = self._build_subtree(
--> 288 self.left, self.depth, floatX(np.asarray(-self.step_size)))
self.left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
self.depth = 0
self.step_size = 0.18995892141289814
289 self.left = tree.right
290
291 self.depth += 1
292 self.accept_sum += tree.accept_sum
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _build_subtree(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), depth=0, epsilon=array(-0.18995892141289814))
344 tree = Subtree(None, None, None, None, -np.inf, 0, 1)
345 return tree, (error_msg, error, left), False
346
347 def _build_subtree(self, left, depth, epsilon):
348 if depth == 0:
--> 349 return self._single_step(left, epsilon)
self._single_step = <bound method _Tree._single_step of <pymc3.step_methods.hmc.nuts._Tree object>>
left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
epsilon = array(-0.18995892141289814)
350
351 tree1, diverging, turning = self._build_subtree(left, depth - 1, epsilon)
352 if diverging or turning:
353 return tree1, diverging, turning
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _single_step(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), epsilon=array(-0.18995892141289814))
309 return diverging, turning
310
311 def _single_step(self, left, epsilon):
312 """Perform a leapfrog step and handle error cases."""
313 try:
--> 314 right = self.leapfrog(left.q, left.p, left.q_grad, epsilon)
right = undefined
self.leapfrog = <theano.compile.function_module.Function object>
left.q = array([ 5.35573599, 5.35573599])
left.p = array([-0.29184532, -0.39283626])
left.q_grad = array([ 17779.4151146 , -9058.04433461])
epsilon = array(-0.18995892141289814)
315 except linalg.LinAlgError as err:
316 error_msg = "LinAlgError during leapfrog step."
317 error = err
318 except ValueError as err:
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
893 if hasattr(self.fn, 'thunks'):
894 thunk = self.fn.thunks[self.fn.position_of_error]
895 gof.link.raise_with_op(
896 node=self.fn.nodes[self.fn.position_of_error],
897 thunk=thunk,
--> 898 storage_map=getattr(self.fn, 'storage_map', None))
self.fn = <theano.gof.vm.CVM object>
899 else:
900 # old-style linkers raise their own exceptions
901 raise
902
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/gof/link.py in raise_with_op(node=Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i...}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0), thunk=<function Op.make_c_thunk.<locals>.rval>, exc_info=(<class 'TypeError'>, TypeError('expected type_num 1 (NPY_INT8) got 7',), <traceback object>), storage_map={TensorConstant{-0.0032723..4201266718}: [array(-0.0032723434201266718)], Reshape{1}.0: [None], Elemwise{Composite{Switch(GE(i0, (Composite{Swit...GE(i0, i1), i1, i0)}(i0, i1))}(i1, i2, i3))))}}.0: [None], Elemwise{eq,no_inplace}.0: [array([False, False, False, False, False, False,..., False,
False, False, False], dtype=bool)], lambda_1: [None], Elemwise{Composite{Identity(GT(i0, i1))}}.0: [array(1)], epsilon: [array(-0.18995892141289814)], Elemwise{Composite{(i0 + (i1 * i2 * i3))}}.0: [None], InplaceDimShuffle{x}.0: [array([-0.18995892])], Elemwise{exp}.0: [array(2.415049280601321e-69)], ...})
320 print("WARNING: %s error does not allow us to add extra error message" %
321 str(exc_type))
322 # Some exception need extra parameter in inputs. So forget the
323 # extra long error message in that case.
324 pass
--> 325 reraise(exc_type, exc_value, exc_trace)
exc_type = <class 'TypeError'>
exc_value = TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",)
exc_trace = <traceback object>
326
327
328 class Linker(object):
329 """
...........................................................................
/usr/lib/python3/dist-packages/six.py in reraise(tp=<class 'TypeError'>, value=TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",), tb=<traceback object>)
680
681 def reraise(tp, value, tb=None):
682 if value is None:
683 value = tp()
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
value.with_traceback = <built-in method with_traceback of TypeError object>
tb = <traceback object>
686 raise value
687
688 else:
689 def exec_(_code_, _globs_=None, _locs_=None):
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
879
880 # Do the actual work
881 t0_fn = time.time()
882 try:
883 outputs =\
--> 884 self.fn() if output_subset is None else\
self.fn = <theano.gof.vm.CVM object>
output_subset = None
885 self.fn(output_subset=output_subset)
886 except Exception:
887 restore_defaults()
888 if hasattr(self.fn, 'position_of_error'):
TypeError: expected type_num 1 (NPY_INT8) got 7
Apply node that caused the error: Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)](TensorConstant{1.0}, Elemwise{Composite{Identity(GT(i0, i1))}}.0, TensorConstant{-0.0032723..4201266718}, Elemwise{exp,no_inplace}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0)
Toposort index: 53
Inputs types: [TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar)]
Inputs shapes: [(), (), (), (), (), ()]
Inputs strides: [(), (), (), (), (), ()]
Inputs values: [array(1.0), array(1), array(-0.0032723434201266718), array(4.6014303593244465e+141), array(0, dtype=int8), array(-45.0)]
Outputs clients: [[Reshape{1}(Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)].0, TensorConstant{(1,) of -1})]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
___________________________________________________________________________
During handling of the above exception, another exception occurred:
JoblibTypeError Traceback (most recent call last)
<ipython-input-12-0b97c5e035d7> in <module>()
1 #Number of days spaned by the original series
2 days = len(fem_cases)
----> 3 trace = switchpoint(fem_cases, days)
<ipython-input-9-fe0f67546b7d> in switchpoint(fem_cases, days)
26 lambda_ = pm.math.switch(tau >= idx, lambda_1, lambda_2)
27 observation = pm.Poisson("obs", lambda_, observed=fem_cases)
---> 28 trace = pm.sample(2000, tune=2000, njobs=3)
29 gc.collect()
30 return trace
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, nuts_kwargs, step_kwargs, progressbar, model, random_seed, live_plot, discard_tuned_samples, live_plot_kwargs, **kwargs)
274 discard = tune if discard_tuned_samples else 0
275
--> 276 return sample_func(**sample_args)[discard:]
277
278
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _mp_sample(**kwargs)
460 random_seed=rseed[i],
461 start=start_vals[i],
--> 462 **kwargs) for i in range(njobs))
463 return merge_traces(traces)
464
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self, iterable)
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in retrieve(self)
738 exception = exception_type(report)
739
--> 740 raise exception
741
742 def __call__(self, iterable):
JoblibTypeError: JoblibTypeError
___________________________________________________________________________
Multiprocessing exception:
...........................................................................
/usr/lib/python3.5/runpy.py in _run_module_as_main(mod_name='ipykernel_launcher', alter_argv=1)
179 sys.exit(msg)
180 main_globals = sys.modules["__main__"].__dict__
181 if alter_argv:
182 sys.argv[0] = mod_spec.origin
183 return _run_code(code, main_globals, None,
--> 184 "__main__", mod_spec)
mod_spec = ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py')
185
186 def run_module(mod_name, init_globals=None,
187 run_name=None, alter_sys=False):
188 """Execute a module's code without importing it
...........................................................................
/usr/lib/python3.5/runpy.py in _run_code(code=<code object <module> at 0x7f9069deab70, file "/...3.5/dist-packages/ipykernel_launcher.py", line 5>, run_globals={'__builtins__': <module 'builtins' (built-in)>, '__cached__': '/usr/local/lib/python3.5/dist-packages/__pycache__/ipykernel_launcher.cpython-35.pyc', '__doc__': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', '__file__': '/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': '__main__', '__package__': '', '__spec__': ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from '/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py'>, 'sys': <module 'sys' (built-in)>}, init_globals=None, mod_name='__main__', mod_spec=ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), pkg_name='', script_name=None)
80 __cached__ = cached,
81 __doc__ = None,
82 __loader__ = loader,
83 __package__ = pkg_name,
84 __spec__ = mod_spec)
---> 85 exec(code, run_globals)
code = <code object <module> at 0x7f9069deab70, file "/...3.5/dist-packages/ipykernel_launcher.py", line 5>
run_globals = {'__builtins__': <module 'builtins' (built-in)>, '__cached__': '/usr/local/lib/python3.5/dist-packages/__pycache__/ipykernel_launcher.cpython-35.pyc', '__doc__': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', '__file__': '/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': '__main__', '__package__': '', '__spec__': ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from '/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py'>, 'sys': <module 'sys' (built-in)>}
86 return run_globals
87
88 def _run_module_code(code, init_globals=None,
89 mod_name=None, mod_spec=None,
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py in <module>()
11 # This is added back by InteractiveShellApp.init_path()
12 if sys.path[0] == '':
13 del sys.path[0]
14
15 from ipykernel import kernelapp as app
---> 16 app.launch_new_instance()
...........................................................................
/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py in launch_instance(cls=<class 'ipykernel.kernelapp.IPKernelApp'>, argv=None, **kwargs={})
653
654 If a global instance already exists, this reinitializes and starts it
655 """
656 app = cls.instance(**kwargs)
657 app.initialize(argv)
--> 658 app.start()
app.start = <bound method IPKernelApp.start of <ipykernel.kernelapp.IPKernelApp object>>
659
660 #-----------------------------------------------------------------------------
661 # utility functions, for convenience
662 #-----------------------------------------------------------------------------
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py in start(self=<ipykernel.kernelapp.IPKernelApp object>)
472 return self.subapp.start()
473 if self.poller is not None:
474 self.poller.start()
475 self.kernel.start()
476 try:
--> 477 ioloop.IOLoop.instance().start()
478 except KeyboardInterrupt:
479 pass
480
481 launch_new_instance = IPKernelApp.launch_instance
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
172 )
173 return loop
174
175 def start(self):
176 try:
--> 177 super(ZMQIOLoop, self).start()
self.start = <bound method ZMQIOLoop.start of <zmq.eventloop.ioloop.ZMQIOLoop object>>
178 except ZMQError as e:
179 if e.errno == ETERM:
180 # quietly return on ETERM
181 pass
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
883 self._events.update(event_pairs)
884 while self._events:
885 fd, events = self._events.popitem()
886 try:
887 fd_obj, handler_func = self._handlers[fd]
--> 888 handler_func(fd_obj, events)
handler_func = <function wrap.<locals>.null_wrapper>
fd_obj = <zmq.sugar.socket.Socket object>
events = 1
889 except (OSError, IOError) as e:
890 if errno_from_exception(e) == errno.EPIPE:
891 # Happens when the client closes the connection
892 pass
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py in null_wrapper(*args=(<zmq.sugar.socket.Socket object>, 1), **kwargs={})
272 # Fast path when there are no active contexts.
273 def null_wrapper(*args, **kwargs):
274 try:
275 current_state = _state.contexts
276 _state.contexts = cap_contexts[0]
--> 277 return fn(*args, **kwargs)
args = (<zmq.sugar.socket.Socket object>, 1)
kwargs = {}
278 finally:
279 _state.contexts = current_state
280 null_wrapper._wrapped = True
281 return null_wrapper
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _handle_events(self=<zmq.eventloop.zmqstream.ZMQStream object>, fd=<zmq.sugar.socket.Socket object>, events=1)
435 # dispatch events:
436 if events & IOLoop.ERROR:
437 gen_log.error("got POLLERR event on ZMQStream, which doesn't make sense")
438 return
439 if events & IOLoop.READ:
--> 440 self._handle_recv()
self._handle_recv = <bound method ZMQStream._handle_recv of <zmq.eventloop.zmqstream.ZMQStream object>>
441 if not self.socket:
442 return
443 if events & IOLoop.WRITE:
444 self._handle_send()
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _handle_recv(self=<zmq.eventloop.zmqstream.ZMQStream object>)
467 gen_log.error("RECV Error: %s"%zmq.strerror(e.errno))
468 else:
469 if self._recv_callback:
470 callback = self._recv_callback
471 # self._recv_callback = None
--> 472 self._run_callback(callback, msg)
self._run_callback = <bound method ZMQStream._run_callback of <zmq.eventloop.zmqstream.ZMQStream object>>
callback = <function wrap.<locals>.null_wrapper>
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
473
474 # self.update_state()
475
476
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _run_callback(self=<zmq.eventloop.zmqstream.ZMQStream object>, callback=<function wrap.<locals>.null_wrapper>, *args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
409 close our socket."""
410 try:
411 # Use a NullContext to ensure that all StackContexts are run
412 # inside our blanket exception handler rather than outside.
413 with stack_context.NullContext():
--> 414 callback(*args, **kwargs)
callback = <function wrap.<locals>.null_wrapper>
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
415 except:
416 gen_log.error("Uncaught exception, closing connection.",
417 exc_info=True)
418 # Close the socket on an uncaught exception from a user callback
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py in null_wrapper(*args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
272 # Fast path when there are no active contexts.
273 def null_wrapper(*args, **kwargs):
274 try:
275 current_state = _state.contexts
276 _state.contexts = cap_contexts[0]
--> 277 return fn(*args, **kwargs)
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
278 finally:
279 _state.contexts = current_state
280 null_wrapper._wrapped = True
281 return null_wrapper
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in dispatcher(msg=[<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>])
278 if self.control_stream:
279 self.control_stream.on_recv(self.dispatch_control, copy=False)
280
281 def make_dispatcher(stream):
282 def dispatcher(msg):
--> 283 return self.dispatch_shell(stream, msg)
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
284 return dispatcher
285
286 for s in self.shell_streams:
287 s.on_recv(make_dispatcher(s), copy=False)
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in dispatch_shell(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, msg={'buffers': [], 'content': {'allow_stdin': True, 'code': '#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 13, 46, 13, 460032, tzinfo=datetime.timezone.utc), 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'parent_header': {}})
230 self.log.warn("Unknown message type: %r", msg_type)
231 else:
232 self.log.debug("%s: %s", msg_type, msg)
233 self.pre_handler_hook()
234 try:
--> 235 handler(stream, idents, msg)
handler = <bound method Kernel.execute_request of <ipykernel.ipkernel.IPythonKernel object>>
stream = <zmq.eventloop.zmqstream.ZMQStream object>
idents = [b'85B0853D17CB4889B2CD009CAB48B30F']
msg = {'buffers': [], 'content': {'allow_stdin': True, 'code': '#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 13, 46, 13, 460032, tzinfo=datetime.timezone.utc), 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'parent_header': {}}
236 except Exception:
237 self.log.error("Exception in message handler:", exc_info=True)
238 finally:
239 self.post_handler_hook()
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in execute_request(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, ident=[b'85B0853D17CB4889B2CD009CAB48B30F'], parent={'buffers': [], 'content': {'allow_stdin': True, 'code': '#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 13, 46, 13, 460032, tzinfo=datetime.timezone.utc), 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '49832BC5C4A34BED8DAA728FFAFAAD7D', 'msg_type': 'execute_request', 'parent_header': {}})
394 if not silent:
395 self.execution_count += 1
396 self._publish_execute_input(code, parent, self.execution_count)
397
398 reply_content = self.do_execute(code, silent, store_history,
--> 399 user_expressions, allow_stdin)
user_expressions = {}
allow_stdin = True
400
401 # Flush output before sending the reply.
402 sys.stdout.flush()
403 sys.stderr.flush()
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/ipkernel.py in do_execute(self=<ipykernel.ipkernel.IPythonKernel object>, code='#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)', silent=False, store_history=True, user_expressions={}, allow_stdin=True)
191
192 self._forward_input(allow_stdin)
193
194 reply_content = {}
195 try:
--> 196 res = shell.run_cell(code, store_history=store_history, silent=silent)
res = undefined
shell.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = '#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)'
store_history = True
silent = False
197 finally:
198 self._restore_input()
199
200 if res.error_before_exec is not None:
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/zmqshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, *args=('#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)',), **kwargs={'silent': False, 'store_history': True})
528 )
529 self.payload_manager.write_payload(payload)
530
531 def run_cell(self, *args, **kwargs):
532 self._last_traceback = None
--> 533 return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
self.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
args = ('#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)',)
kwargs = {'silent': False, 'store_history': True}
534
535 def _showtraceback(self, etype, evalue, stb):
536 # try to preserve ordering of tracebacks and print statements
537 sys.stdout.flush()
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, raw_cell='#Number of days spaned by the original series\nda...n(fem_cases)\ntrace = switchpoint(fem_cases, days)', store_history=True, silent=False, shell_futures=True)
2693 self.displayhook.exec_result = result
2694
2695 # Execute the user code
2696 interactivity = "none" if silent else self.ast_node_interactivity
2697 has_raised = self.run_ast_nodes(code_ast.body, cell_name,
-> 2698 interactivity=interactivity, compiler=compiler, result=result)
interactivity = 'last_expr'
compiler = <IPython.core.compilerop.CachingCompiler object>
2699
2700 self.last_execution_succeeded = not has_raised
2701
2702 # Reset this so later displayed values do not modify the
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_ast_nodes(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, nodelist=[<_ast.Assign object>, <_ast.Assign object>], cell_name='<ipython-input-12-0b97c5e035d7>', interactivity='none', compiler=<IPython.core.compilerop.CachingCompiler object>, result=<ExecutionResult object at 7f90240a15c0, executi..._before_exec=None error_in_exec=None result=None>)
2797
2798 try:
2799 for i, node in enumerate(to_run_exec):
2800 mod = ast.Module([node])
2801 code = compiler(mod, cell_name, "exec")
-> 2802 if self.run_code(code, result):
self.run_code = <bound method InteractiveShell.run_code of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = <code object <module> at 0x7f902ea615d0, file "<ipython-input-12-0b97c5e035d7>", line 3>
result = <ExecutionResult object at 7f90240a15c0, executi..._before_exec=None error_in_exec=None result=None>
2803 return True
2804
2805 for i, node in enumerate(to_run_interactive):
2806 mod = ast.Interactive([node])
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_code(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, code_obj=<code object <module> at 0x7f902ea615d0, file "<ipython-input-12-0b97c5e035d7>", line 3>, result=<ExecutionResult object at 7f90240a15c0, executi..._before_exec=None error_in_exec=None result=None>)
2857 outflag = True # happens in more places, so it's easier as default
2858 try:
2859 try:
2860 self.hooks.pre_run_code_hook()
2861 #rprint('Running code', repr(code_obj)) # dbg
-> 2862 exec(code_obj, self.user_global_ns, self.user_ns)
code_obj = <code object <module> at 0x7f902ea615d0, file "<ipython-input-12-0b97c5e035d7>", line 3>
self.user_global_ns = {'ALLOW_THREADS': 1, 'Annotation': <class 'matplotlib.text.Annotation'>, 'Arrow': <class 'matplotlib.patches.Arrow'>, 'Artist': <class 'matplotlib.artist.Artist'>, 'AutoLocator': <class 'matplotlib.ticker.AutoLocator'>, 'Axes': <class 'matplotlib.axes._axes.Axes'>, 'AxisError': <class 'numpy.core._internal.AxisError'>, 'BUFSIZE': 8192, 'Button': <class 'matplotlib.widgets.Button'>, 'CLIP': 0, ...}
self.user_ns = {'ALLOW_THREADS': 1, 'Annotation': <class 'matplotlib.text.Annotation'>, 'Arrow': <class 'matplotlib.patches.Arrow'>, 'Artist': <class 'matplotlib.artist.Artist'>, 'AutoLocator': <class 'matplotlib.ticker.AutoLocator'>, 'Axes': <class 'matplotlib.axes._axes.Axes'>, 'AxisError': <class 'numpy.core._internal.AxisError'>, 'BUFSIZE': 8192, 'Button': <class 'matplotlib.widgets.Button'>, 'CLIP': 0, ...}
2863 finally:
2864 # Reset our crash handler in place
2865 sys.excepthook = old_excepthook
2866 except SystemExit as e:
...........................................................................
/home/marcio/MEGA/Dissertação/Scripts/<ipython-input-12-0b97c5e035d7> in <module>()
1 #Number of days spaned by the original series
2 days = len(fem_cases)
----> 3 trace = switchpoint(fem_cases, days)
...........................................................................
/home/marcio/MEGA/Dissertação/Scripts/<ipython-input-9-fe0f67546b7d> in switchpoint(fem_cases=DT_NOTIFIC
2015-01-11 2
2015-01-18 2... W-SUN, Name: ID_AGRAVO, Length: 93, dtype: int64, days=93)
23 idx = np.arange(days)
24
25 # buscar função logÃstica (+ suave)
26 lambda_ = pm.math.switch(tau >= idx, lambda_1, lambda_2)
27 observation = pm.Poisson("obs", lambda_, observed=fem_cases)
---> 28 trace = pm.sample(2000, tune=2000, njobs=3)
29 gc.collect()
30 return trace
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws=4000, step=[<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], init='auto', n_init=200000, start=None, trace=None, chain=0, njobs=3, tune=2000, nuts_kwargs=None, step_kwargs=None, progressbar=True, model=<pymc3.model.Model object>, random_seed=-1, live_plot=False, discard_tuned_samples=True, live_plot_kwargs=None, **kwargs={})
271 else:
272 sample_func = _sample
273
274 discard = tune if discard_tuned_samples else 0
275
--> 276 return sample_func(**sample_args)[discard:]
sample_func = <function _mp_sample>
sample_args = {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'njobs': 3, 'progressbar': True, 'random_seed': -1, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], ...}
discard = 2000
277
278
279 def _sample(draws, step=None, start=None, trace=None, chain=0, tune=None,
280 progressbar=True, model=None, random_seed=-1, live_plot=False,
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _mp_sample(**kwargs={'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, 'tune': 2000})
457 pbars = [kwargs.pop('progressbar')] + [False] * (njobs - 1)
458 traces = Parallel(n_jobs=njobs)(delayed(_sample)(chain=chains[i],
459 progressbar=pbars[i],
460 random_seed=rseed[i],
461 start=start_vals[i],
--> 462 **kwargs) for i in range(njobs))
kwargs = {'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, 'tune': 2000}
njobs = 3
463 return merge_traces(traces)
464
465
466 def stop_tuning(step):
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=3), iterable=<generator object _mp_sample.<locals>.<genexpr>>)
784 if pre_dispatch == "all" or n_jobs == 1:
785 # The iterable was consumed all at once by the above for loop.
786 # No need to wait for async callbacks to trigger to
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=3)>
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time
792 self._print('Done %3i out of %3i | elapsed: %s finished',
793 (len(self._output), len(self._output),
---------------------------------------------------------------------------
Sub-process traceback:
---------------------------------------------------------------------------
TypeError Wed Jun 21 10:46:23 2017
PID: 4383 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 4000, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 2070153010, 'start': None, 'step': [<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=4000, step=[<pymc3.step_methods.metropolis.Metropolis object>, <pymc3.step_methods.hmc.nuts.NUTS object>], start=None, trace=None, chain=0, tune=2000, progressbar=True, model=<pymc3.model.Model object>, random_seed=2070153010, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/4000 [00:00<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/4000 [00:00<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=4000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}, trace=None, chain=0, tune=2000, model=<pymc3.model.Model object>, random_seed=2070153010)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(46)}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
state = [{'accept': 1.0, 'tune': True}]
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'lambda_1_log__': array(5.355735990664007), 'lambda_2_log__': array(5.355735990664007), 'tau': array(47)}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([ 5.35573599, 5.35573599]))
184 start = Edge(q0, p0, v0, self.dlogp(q0), start_energy)
185 tree = _Tree(len(p0), self.leapfrog, start, step_size, self.Emax)
186
187 for _ in range(self.max_treedepth):
188 direction = logbern(np.log(0.5)) * 2 - 1
--> 189 diverging, turning = tree.extend(direction)
diverging = undefined
turning = undefined
tree.extend = <bound method _Tree.extend of <pymc3.step_methods.hmc.nuts._Tree object>>
direction = -1
190 q = tree.proposal.q
191
192 if diverging or turning:
193 if diverging:
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in extend(self=<pymc3.step_methods.hmc.nuts._Tree object>, direction=-1)
283 tree, diverging, turning = self._build_subtree(
284 self.right, self.depth, floatX(np.asarray(self.step_size)))
285 self.right = tree.right
286 else:
287 tree, diverging, turning = self._build_subtree(
--> 288 self.left, self.depth, floatX(np.asarray(-self.step_size)))
self.left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
self.depth = 0
self.step_size = 0.18995892141289814
289 self.left = tree.right
290
291 self.depth += 1
292 self.accept_sum += tree.accept_sum
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _build_subtree(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), depth=0, epsilon=array(-0.18995892141289814))
344 tree = Subtree(None, None, None, None, -np.inf, 0, 1)
345 return tree, (error_msg, error, left), False
346
347 def _build_subtree(self, left, depth, epsilon):
348 if depth == 0:
--> 349 return self._single_step(left, epsilon)
self._single_step = <bound method _Tree._single_step of <pymc3.step_methods.hmc.nuts._Tree object>>
left = Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601))
epsilon = array(-0.18995892141289814)
350
351 tree1, diverging, turning = self._build_subtree(left, depth - 1, epsilon)
352 if diverging or turning:
353 return tree1, diverging, turning
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in _single_step(self=<pymc3.step_methods.hmc.nuts._Tree object>, left=Edge(q=array([ 5.35573599, 5.35573599]), p=arra...9058.04433461]), energy=array(32889.11665647601)), epsilon=array(-0.18995892141289814))
309 return diverging, turning
310
311 def _single_step(self, left, epsilon):
312 """Perform a leapfrog step and handle error cases."""
313 try:
--> 314 right = self.leapfrog(left.q, left.p, left.q_grad, epsilon)
right = undefined
self.leapfrog = <theano.compile.function_module.Function object>
left.q = array([ 5.35573599, 5.35573599])
left.p = array([-0.29184532, -0.39283626])
left.q_grad = array([ 17779.4151146 , -9058.04433461])
epsilon = array(-0.18995892141289814)
315 except linalg.LinAlgError as err:
316 error_msg = "LinAlgError during leapfrog step."
317 error = err
318 except ValueError as err:
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
893 if hasattr(self.fn, 'thunks'):
894 thunk = self.fn.thunks[self.fn.position_of_error]
895 gof.link.raise_with_op(
896 node=self.fn.nodes[self.fn.position_of_error],
897 thunk=thunk,
--> 898 storage_map=getattr(self.fn, 'storage_map', None))
self.fn = <theano.gof.vm.CVM object>
899 else:
900 # old-style linkers raise their own exceptions
901 raise
902
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/gof/link.py in raise_with_op(node=Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i...}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0), thunk=<function Op.make_c_thunk.<locals>.rval>, exc_info=(<class 'TypeError'>, TypeError('expected type_num 1 (NPY_INT8) got 7',), <traceback object>), storage_map={TensorConstant{-0.0032723..4201266718}: [array(-0.0032723434201266718)], Reshape{1}.0: [None], Elemwise{Composite{Switch(GE(i0, (Composite{Swit...GE(i0, i1), i1, i0)}(i0, i1))}(i1, i2, i3))))}}.0: [None], Elemwise{eq,no_inplace}.0: [array([False, False, False, False, False, False,..., False,
False, False, False], dtype=bool)], lambda_1: [None], Elemwise{Composite{Identity(GT(i0, i1))}}.0: [array(1)], epsilon: [array(-0.18995892141289814)], Elemwise{Composite{(i0 + (i1 * i2 * i3))}}.0: [None], InplaceDimShuffle{x}.0: [array([-0.18995892])], Elemwise{exp}.0: [array(2.415049280601321e-69)], ...})
320 print("WARNING: %s error does not allow us to add extra error message" %
321 str(exc_type))
322 # Some exception need extra parameter in inputs. So forget the
323 # extra long error message in that case.
324 pass
--> 325 reraise(exc_type, exc_value, exc_trace)
exc_type = <class 'TypeError'>
exc_value = TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",)
exc_trace = <traceback object>
326
327
328 class Linker(object):
329 """
...........................................................................
/usr/lib/python3/dist-packages/six.py in reraise(tp=<class 'TypeError'>, value=TypeError("expected type_num 1 (NPY_INT8) got 7\... and storage map footprint of this apply node.",), tb=<traceback object>)
680
681 def reraise(tp, value, tb=None):
682 if value is None:
683 value = tp()
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
value.with_traceback = <built-in method with_traceback of TypeError object>
tb = <traceback object>
686 raise value
687
688 else:
689 def exec_(_code_, _globs_=None, _locs_=None):
...........................................................................
/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py in __call__(self=<theano.compile.function_module.Function object>, *args=(array([ 5.35573599, 5.35573599]), array([-0.29184532, -0.39283626]), array([ 17779.4151146 , -9058.04433461]), array(-0.18995892141289814)), **kwargs={})
879
880 # Do the actual work
881 t0_fn = time.time()
882 try:
883 outputs =\
--> 884 self.fn() if output_subset is None else\
self.fn = <theano.gof.vm.CVM object>
output_subset = None
885 self.fn(output_subset=output_subset)
886 except Exception:
887 restore_defaults()
888 if hasattr(self.fn, 'position_of_error'):
TypeError: expected type_num 1 (NPY_INT8) got 7
Apply node that caused the error: Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)](TensorConstant{1.0}, Elemwise{Composite{Identity(GT(i0, i1))}}.0, TensorConstant{-0.0032723..4201266718}, Elemwise{exp,no_inplace}.0, TensorConstant{0}, Sum{acc_dtype=float64}.0)
Toposort index: 53
Inputs types: [TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar), TensorType(float64, scalar), TensorType(int8, scalar), TensorType(float64, scalar)]
Inputs shapes: [(), (), (), (), (), ()]
Inputs strides: [(), (), (), (), (), ()]
Inputs values: [array(1.0), array(1), array(-0.0032723434201266718), array(4.6014303593244465e+141), array(0, dtype=int8), array(-45.0)]
Outputs clients: [[Reshape{1}(Elemwise{Composite{(i0 + Switch(i1, (i2 * i3), i4) + (i5 * i3))}}[(0, 5)].0, TensorConstant{(1,) of -1})]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
___________________________________________________________________________
@aseyboldt This model is a prerequisite for the former one.
This looks similar to the previous error, there seem to be mismatching types somewhere in the model or one of the distributions. Without the code for the model and if at all possible a small (simulated?) dataset there is nothing I can do to track that down further.
@aseyboldt The same error appears even when there is no likelihood.
Anyways here it goes a minibatch:
loss_shifted40
2016-01-03 155
2016-01-10 267
2016-01-17 105
2016-01-24 223
2016-01-31 183
2016-02-07 189
2016-02-14 262
2016-02-21 178
2016-02-28 272
2016-03-06 187
fem_cases
2015-01-11 2
2015-01-18 2
2015-01-25 2
2015-02-01 3
2015-02-08 1
2015-02-15 0
2015-02-22 1
2015-03-01 0
2015-03-08 0
2015-03-15 0
mz_freq
2016-01-03 0.05
2016-01-10 0.047
2016-01-17 0.045
2016-01-24 0.063
2016-01-31 0.06
2016-02-07 0.062
2016-02-14 0.053
2016-02-21 0.057
2016-02-28 0.061
2016-03-06 0.058
I can't seem to reproduce the theano error. Could you try to delete the theano cache (~/.theano), in my experience that can lead to trouble from time to time. This works for me:
loss_shifted40 = [155, 267, 105, 223, 183, 189, 262, 178, 272, 187]
fem_cases = [2, 2, 2, 3, 1, 0, 1, 0, 0, 0]
mz_freq = [0.05, 0.047, 0.045, 0.063, 0.06, 0.062, 0.053, 0.057, 0.061, 0.058]
loss_shifted40 = pd.DataFrame(loss_shifted40)
fem_cases = pd.DataFrame(fem_cases)
mz_freq = pd.DataFrame(mz_freq)
pp_mean = 0.05
N = len(loss_shifted40)
with pm.Model() as zika_model:
pp = pm.Uniform("pp", lower=pp_mean/3, upper=(5/3)*pp_mean)
upper_beta = pm.Exponential("upper_beta", lam=1/2, testval=3)
beta = pm.Uniform("beta", lower=0.5, upper=upper_beta)
beta_gamma = pm.Exponential("beta_gamma", lam=60)
alpha_gamma_mean = pm.Deterministic("alpha_gamma_mean", var=beta_gamma/7)
alpha_gamma = pm.Exponential("alpha_gamma", lam=alpha_gamma_mean)
gamma = pm.Gamma("gamma", alpha=alpha_gamma, beta=beta_gamma, testval=1/7)
I = pm.Uniform("I", lower=0, upper=fem_cases.sum(), shape=len(fem_cases))
R = pm.Deterministic("R", gamma*I)
S = pm.Uniform("S", lower=0, upper=N-(I+R), shape=len(fem_cases))
inc = pm.Deterministic("inc", beta*I*(S)/(S+I+R)-R)
po = pm.Uniform("po", lower=0, upper=1)
Y = pm.Poisson('Y', mu=inc, shape=len(fem_cases), testval=np.ones(N, dtype=int))
mu_Yo = pm.Deterministic("mu_Yo", var=Y*po)
Yp = pm.Poisson("Yp", mu=Y*pp, shape=len(fem_cases), testval=300 * np.ones(N, dtype=int))
with zika_model:
Yo = pm.Poisson('Yo', mu=mu_Yo, observed=fem_cases)
mz = pm.Beta("mz", alpha=1, beta=1, observed=mz_freq)
M = pm.Binomial("M", n=Yp, p=mz, observed=loss_shifted40)
with zika_model:
trace = pm.sample(5e3, progressbar=True, njobs=2)
I had to set testvals for upper_beta and Yp, or the initial position would have been invalid (more successes than total trials in M = pm.Binomial("M", n=Yp, p=mz, observed=loss_shifted40)).
I didn't check convergence in any way though.
Oh, one other possibility would be the dtype of the dataframes. What is the output of fem_cases.dtypes and loss_shifted40.dtypes?
I have set fem_case and loss_shifted40 to int32 (even though it's oversized)
After removing (~/.theano), the first model (the second error I pasted) back to work fine, but the second show the follow error:
RemoteTraceback Traceback (most recent call last)
RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/joblib/_parallel_backends.py", line 350, in __call__
return self.func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/joblib/parallel.py", line 131, in __call__
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/usr/local/lib/python3.5/dist-packages/joblib/parallel.py", line 131, in <listcomp>
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 291, in _sample
for it, strace in enumerate(sampling):
File "/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py", line 862, in __iter__
for obj in iterable:
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 389, in _iter_sample
point, states = step.step(point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py", line 24, in step
point, state = method.step(point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py", line 152, in step
apoint, stats = self.astep(bij.map(point))
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py", line 175, in astep
'might be misspecified.' % start_energy)
ValueError: Bad initial energy: inf. The model might be misspecified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.5/dist-packages/joblib/_parallel_backends.py", line 359, in __call__
raise TransportableException(text, e_type)
joblib.my_exceptions.TransportableException: TransportableException
___________________________________________________________________________
ValueError Wed Jun 21 13:37:40 2017
PID: 12809 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=1000.0, step=[<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], start=None, trace=None, chain=0, tune=500, progressbar=True, model=<pymc3.model.Model object>, random_seed=63967813, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/1000.0 [00:04<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/1000.0 [00:04<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=1000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}, trace=None, chain=0, tune=500, model=<pymc3.model.Model object>, random_seed=63967813)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
state = undefined
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([-2.37627281, 0. , 0. , 0... ,
-2.06216105, 0.32663426, 0. ]))
170 p0 = self.potential.random()
171 v0 = self.compute_velocity(p0)
172 start_energy = self.compute_energy(q0, p0)
173 if not np.isfinite(start_energy):
174 raise ValueError('Bad initial energy: %s. The model '
--> 175 'might be misspecified.' % start_energy)
start_energy = array(inf)
176
177 if not self.adapt_step_size:
178 step_size = self.step_size
179 elif self.tune:
ValueError: Bad initial energy: inf. The model might be misspecified.
___________________________________________________________________________
"""
The above exception was the direct cause of the following exception:
TransportableException Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in retrieve(self)
698 if getattr(self._backend, 'supports_timeout', False):
--> 699 self._output.extend(job.get(timeout=self.timeout))
700 else:
/usr/lib/python3.5/multiprocessing/pool.py in get(self, timeout)
607 else:
--> 608 raise self._value
609
TransportableException: TransportableException
___________________________________________________________________________
ValueError Wed Jun 21 13:37:40 2017
PID: 12809 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=1000.0, step=[<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], start=None, trace=None, chain=0, tune=500, progressbar=True, model=<pymc3.model.Model object>, random_seed=63967813, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/1000.0 [00:04<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/1000.0 [00:04<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=1000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}, trace=None, chain=0, tune=500, model=<pymc3.model.Model object>, random_seed=63967813)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
state = undefined
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([-2.37627281, 0. , 0. , 0... ,
-2.06216105, 0.32663426, 0. ]))
170 p0 = self.potential.random()
171 v0 = self.compute_velocity(p0)
172 start_energy = self.compute_energy(q0, p0)
173 if not np.isfinite(start_energy):
174 raise ValueError('Bad initial energy: %s. The model '
--> 175 'might be misspecified.' % start_energy)
start_energy = array(inf)
176
177 if not self.adapt_step_size:
178 step_size = self.step_size
179 elif self.tune:
ValueError: Bad initial energy: inf. The model might be misspecified.
___________________________________________________________________________
During handling of the above exception, another exception occurred:
JoblibValueError Traceback (most recent call last)
<ipython-input-42-f26587c521c0> in <module>()
3 # trace = pm.backends.text.load('trace')
4 # db = pm.backends.Text('trace')
----> 5 trace = pm.sample(5e2, njobs=2, progressbar=True)
6 # trace = pm.sample(5e4, njobs=2, step=[pm.HamiltonianMC(scaling=trace[-1]), pm.NUTS(scaling=trace[-1])], start=trace[-1], tune=1000, progressbar=True, trace=db)
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, nuts_kwargs, step_kwargs, progressbar, model, random_seed, live_plot, discard_tuned_samples, live_plot_kwargs, **kwargs)
274 discard = tune if discard_tuned_samples else 0
275
--> 276 return sample_func(**sample_args)[discard:]
277
278
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _mp_sample(**kwargs)
460 random_seed=rseed[i],
461 start=start_vals[i],
--> 462 **kwargs) for i in range(njobs))
463 return merge_traces(traces)
464
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self, iterable)
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in retrieve(self)
738 exception = exception_type(report)
739
--> 740 raise exception
741
742 def __call__(self, iterable):
JoblibValueError: JoblibValueError
___________________________________________________________________________
Multiprocessing exception:
...........................................................................
/usr/lib/python3.5/runpy.py in _run_module_as_main(mod_name='ipykernel_launcher', alter_argv=1)
179 sys.exit(msg)
180 main_globals = sys.modules["__main__"].__dict__
181 if alter_argv:
182 sys.argv[0] = mod_spec.origin
183 return _run_code(code, main_globals, None,
--> 184 "__main__", mod_spec)
mod_spec = ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py')
185
186 def run_module(mod_name, init_globals=None,
187 run_name=None, alter_sys=False):
188 """Execute a module's code without importing it
...........................................................................
/usr/lib/python3.5/runpy.py in _run_code(code=<code object <module> at 0x7f5ab352ab70, file "/...3.5/dist-packages/ipykernel_launcher.py", line 5>, run_globals={'__builtins__': <module 'builtins' (built-in)>, '__cached__': '/usr/local/lib/python3.5/dist-packages/__pycache__/ipykernel_launcher.cpython-35.pyc', '__doc__': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', '__file__': '/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': '__main__', '__package__': '', '__spec__': ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from '/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py'>, 'sys': <module 'sys' (built-in)>}, init_globals=None, mod_name='__main__', mod_spec=ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), pkg_name='', script_name=None)
80 __cached__ = cached,
81 __doc__ = None,
82 __loader__ = loader,
83 __package__ = pkg_name,
84 __spec__ = mod_spec)
---> 85 exec(code, run_globals)
code = <code object <module> at 0x7f5ab352ab70, file "/...3.5/dist-packages/ipykernel_launcher.py", line 5>
run_globals = {'__builtins__': <module 'builtins' (built-in)>, '__cached__': '/usr/local/lib/python3.5/dist-packages/__pycache__/ipykernel_launcher.cpython-35.pyc', '__doc__': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', '__file__': '/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': '__main__', '__package__': '', '__spec__': ModuleSpec(name='ipykernel_launcher', loader=<_f...b/python3.5/dist-packages/ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from '/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py'>, 'sys': <module 'sys' (built-in)>}
86 return run_globals
87
88 def _run_module_code(code, init_globals=None,
89 mod_name=None, mod_spec=None,
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py in <module>()
11 # This is added back by InteractiveShellApp.init_path()
12 if sys.path[0] == '':
13 del sys.path[0]
14
15 from ipykernel import kernelapp as app
---> 16 app.launch_new_instance()
...........................................................................
/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py in launch_instance(cls=<class 'ipykernel.kernelapp.IPKernelApp'>, argv=None, **kwargs={})
653
654 If a global instance already exists, this reinitializes and starts it
655 """
656 app = cls.instance(**kwargs)
657 app.initialize(argv)
--> 658 app.start()
app.start = <bound method IPKernelApp.start of <ipykernel.kernelapp.IPKernelApp object>>
659
660 #-----------------------------------------------------------------------------
661 # utility functions, for convenience
662 #-----------------------------------------------------------------------------
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelapp.py in start(self=<ipykernel.kernelapp.IPKernelApp object>)
472 return self.subapp.start()
473 if self.poller is not None:
474 self.poller.start()
475 self.kernel.start()
476 try:
--> 477 ioloop.IOLoop.instance().start()
478 except KeyboardInterrupt:
479 pass
480
481 launch_new_instance = IPKernelApp.launch_instance
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
172 )
173 return loop
174
175 def start(self):
176 try:
--> 177 super(ZMQIOLoop, self).start()
self.start = <bound method ZMQIOLoop.start of <zmq.eventloop.ioloop.ZMQIOLoop object>>
178 except ZMQError as e:
179 if e.errno == ETERM:
180 # quietly return on ETERM
181 pass
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/ioloop.py in start(self=<zmq.eventloop.ioloop.ZMQIOLoop object>)
883 self._events.update(event_pairs)
884 while self._events:
885 fd, events = self._events.popitem()
886 try:
887 fd_obj, handler_func = self._handlers[fd]
--> 888 handler_func(fd_obj, events)
handler_func = <function wrap.<locals>.null_wrapper>
fd_obj = <zmq.sugar.socket.Socket object>
events = 5
889 except (OSError, IOError) as e:
890 if errno_from_exception(e) == errno.EPIPE:
891 # Happens when the client closes the connection
892 pass
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py in null_wrapper(*args=(<zmq.sugar.socket.Socket object>, 5), **kwargs={})
272 # Fast path when there are no active contexts.
273 def null_wrapper(*args, **kwargs):
274 try:
275 current_state = _state.contexts
276 _state.contexts = cap_contexts[0]
--> 277 return fn(*args, **kwargs)
args = (<zmq.sugar.socket.Socket object>, 5)
kwargs = {}
278 finally:
279 _state.contexts = current_state
280 null_wrapper._wrapped = True
281 return null_wrapper
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _handle_events(self=<zmq.eventloop.zmqstream.ZMQStream object>, fd=<zmq.sugar.socket.Socket object>, events=5)
435 # dispatch events:
436 if events & IOLoop.ERROR:
437 gen_log.error("got POLLERR event on ZMQStream, which doesn't make sense")
438 return
439 if events & IOLoop.READ:
--> 440 self._handle_recv()
self._handle_recv = <bound method ZMQStream._handle_recv of <zmq.eventloop.zmqstream.ZMQStream object>>
441 if not self.socket:
442 return
443 if events & IOLoop.WRITE:
444 self._handle_send()
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _handle_recv(self=<zmq.eventloop.zmqstream.ZMQStream object>)
467 gen_log.error("RECV Error: %s"%zmq.strerror(e.errno))
468 else:
469 if self._recv_callback:
470 callback = self._recv_callback
471 # self._recv_callback = None
--> 472 self._run_callback(callback, msg)
self._run_callback = <bound method ZMQStream._run_callback of <zmq.eventloop.zmqstream.ZMQStream object>>
callback = <function wrap.<locals>.null_wrapper>
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
473
474 # self.update_state()
475
476
...........................................................................
/usr/local/lib/python3.5/dist-packages/zmq/eventloop/zmqstream.py in _run_callback(self=<zmq.eventloop.zmqstream.ZMQStream object>, callback=<function wrap.<locals>.null_wrapper>, *args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
409 close our socket."""
410 try:
411 # Use a NullContext to ensure that all StackContexts are run
412 # inside our blanket exception handler rather than outside.
413 with stack_context.NullContext():
--> 414 callback(*args, **kwargs)
callback = <function wrap.<locals>.null_wrapper>
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
415 except:
416 gen_log.error("Uncaught exception, closing connection.",
417 exc_info=True)
418 # Close the socket on an uncaught exception from a user callback
...........................................................................
/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py in null_wrapper(*args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
272 # Fast path when there are no active contexts.
273 def null_wrapper(*args, **kwargs):
274 try:
275 current_state = _state.contexts
276 _state.contexts = cap_contexts[0]
--> 277 return fn(*args, **kwargs)
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
278 finally:
279 _state.contexts = current_state
280 null_wrapper._wrapped = True
281 return null_wrapper
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in dispatcher(msg=[<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>])
278 if self.control_stream:
279 self.control_stream.on_recv(self.dispatch_control, copy=False)
280
281 def make_dispatcher(stream):
282 def dispatcher(msg):
--> 283 return self.dispatch_shell(stream, msg)
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
284 return dispatcher
285
286 for s in self.shell_streams:
287 s.on_recv(make_dispatcher(s), copy=False)
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in dispatch_shell(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, msg={'buffers': [], 'content': {'allow_stdin': True, 'code': 'with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 16, 36, 19, 699880, tzinfo=datetime.timezone.utc), 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'parent_header': {}})
230 self.log.warn("Unknown message type: %r", msg_type)
231 else:
232 self.log.debug("%s: %s", msg_type, msg)
233 self.pre_handler_hook()
234 try:
--> 235 handler(stream, idents, msg)
handler = <bound method Kernel.execute_request of <ipykernel.ipkernel.IPythonKernel object>>
stream = <zmq.eventloop.zmqstream.ZMQStream object>
idents = [b'85B0853D17CB4889B2CD009CAB48B30F']
msg = {'buffers': [], 'content': {'allow_stdin': True, 'code': 'with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 16, 36, 19, 699880, tzinfo=datetime.timezone.utc), 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'parent_header': {}}
236 except Exception:
237 self.log.error("Exception in message handler:", exc_info=True)
238 finally:
239 self.post_handler_hook()
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/kernelbase.py in execute_request(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, ident=[b'85B0853D17CB4889B2CD009CAB48B30F'], parent={'buffers': [], 'content': {'allow_stdin': True, 'code': 'with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)', 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2017, 6, 21, 16, 36, 19, 699880, tzinfo=datetime.timezone.utc), 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'session': '85B0853D17CB4889B2CD009CAB48B30F', 'username': 'username', 'version': '5.0'}, 'metadata': {}, 'msg_id': '43EFF003CDB24ED089C4400A1D60CF72', 'msg_type': 'execute_request', 'parent_header': {}})
394 if not silent:
395 self.execution_count += 1
396 self._publish_execute_input(code, parent, self.execution_count)
397
398 reply_content = self.do_execute(code, silent, store_history,
--> 399 user_expressions, allow_stdin)
user_expressions = {}
allow_stdin = True
400
401 # Flush output before sending the reply.
402 sys.stdout.flush()
403 sys.stderr.flush()
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/ipkernel.py in do_execute(self=<ipykernel.ipkernel.IPythonKernel object>, code='with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)', silent=False, store_history=True, user_expressions={}, allow_stdin=True)
191
192 self._forward_input(allow_stdin)
193
194 reply_content = {}
195 try:
--> 196 res = shell.run_cell(code, store_history=store_history, silent=silent)
res = undefined
shell.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = 'with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)'
store_history = True
silent = False
197 finally:
198 self._restore_input()
199
200 if res.error_before_exec is not None:
...........................................................................
/usr/local/lib/python3.5/dist-packages/ipykernel/zmqshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, *args=('with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)',), **kwargs={'silent': False, 'store_history': True})
528 )
529 self.payload_manager.write_payload(payload)
530
531 def run_cell(self, *args, **kwargs):
532 self._last_traceback = None
--> 533 return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
self.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
args = ('with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)',)
kwargs = {'silent': False, 'store_history': True}
534
535 def _showtraceback(self, etype, evalue, stb):
536 # try to preserve ordering of tracebacks and print statements
537 sys.stdout.flush()
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, raw_cell='with zika_model:\n# v_params = pm.variational...trace[-1], tune=1000, progressbar=True, trace=db)', store_history=True, silent=False, shell_futures=True)
2693 self.displayhook.exec_result = result
2694
2695 # Execute the user code
2696 interactivity = "none" if silent else self.ast_node_interactivity
2697 has_raised = self.run_ast_nodes(code_ast.body, cell_name,
-> 2698 interactivity=interactivity, compiler=compiler, result=result)
interactivity = 'last_expr'
compiler = <IPython.core.compilerop.CachingCompiler object>
2699
2700 self.last_execution_succeeded = not has_raised
2701
2702 # Reset this so later displayed values do not modify the
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_ast_nodes(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, nodelist=[<_ast.With object>], cell_name='<ipython-input-42-f26587c521c0>', interactivity='none', compiler=<IPython.core.compilerop.CachingCompiler object>, result=<ExecutionResult object at 7f5a4746d550, executi..._before_exec=None error_in_exec=None result=None>)
2797
2798 try:
2799 for i, node in enumerate(to_run_exec):
2800 mod = ast.Module([node])
2801 code = compiler(mod, cell_name, "exec")
-> 2802 if self.run_code(code, result):
self.run_code = <bound method InteractiveShell.run_code of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = <code object <module> at 0x7f5a6d50d390, file "<ipython-input-42-f26587c521c0>", line 1>
result = <ExecutionResult object at 7f5a4746d550, executi..._before_exec=None error_in_exec=None result=None>
2803 return True
2804
2805 for i, node in enumerate(to_run_interactive):
2806 mod = ast.Interactive([node])
...........................................................................
/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py in run_code(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, code_obj=<code object <module> at 0x7f5a6d50d390, file "<ipython-input-42-f26587c521c0>", line 1>, result=<ExecutionResult object at 7f5a4746d550, executi..._before_exec=None error_in_exec=None result=None>)
2857 outflag = True # happens in more places, so it's easier as default
2858 try:
2859 try:
2860 self.hooks.pre_run_code_hook()
2861 #rprint('Running code', repr(code_obj)) # dbg
-> 2862 exec(code_obj, self.user_global_ns, self.user_ns)
code_obj = <code object <module> at 0x7f5a6d50d390, file "<ipython-input-42-f26587c521c0>", line 1>
self.user_global_ns = {'ALLOW_THREADS': 1, 'Annotation': <class 'matplotlib.text.Annotation'>, 'Arrow': <class 'matplotlib.patches.Arrow'>, 'Artist': <class 'matplotlib.artist.Artist'>, 'AutoLocator': <class 'matplotlib.ticker.AutoLocator'>, 'Axes': <class 'matplotlib.axes._axes.Axes'>, 'AxisError': <class 'numpy.core._internal.AxisError'>, 'BUFSIZE': 8192, 'Button': <class 'matplotlib.widgets.Button'>, 'CLIP': 0, ...}
self.user_ns = {'ALLOW_THREADS': 1, 'Annotation': <class 'matplotlib.text.Annotation'>, 'Arrow': <class 'matplotlib.patches.Arrow'>, 'Artist': <class 'matplotlib.artist.Artist'>, 'AutoLocator': <class 'matplotlib.ticker.AutoLocator'>, 'Axes': <class 'matplotlib.axes._axes.Axes'>, 'AxisError': <class 'numpy.core._internal.AxisError'>, 'BUFSIZE': 8192, 'Button': <class 'matplotlib.widgets.Button'>, 'CLIP': 0, ...}
2863 finally:
2864 # Reset our crash handler in place
2865 sys.excepthook = old_excepthook
2866 except SystemExit as e:
...........................................................................
/home/marcio/MEGA/Dissertação/Scripts/<ipython-input-42-f26587c521c0> in <module>()
1 with zika_model:
2 # v_params = pm.variational.advi(n=50000)
3 # trace = pm.backends.text.load('trace')
4 # db = pm.backends.Text('trace')
----> 5 trace = pm.sample(5e2, njobs=2, progressbar=True)
6 # trace = pm.sample(5e4, njobs=2, step=[pm.HamiltonianMC(scaling=trace[-1]), pm.NUTS(scaling=trace[-1])], start=trace[-1], tune=1000, progressbar=True, trace=db)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws=1000.0, step=[<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], init='auto', n_init=200000, start=None, trace=None, chain=0, njobs=2, tune=500, nuts_kwargs=None, step_kwargs=None, progressbar=True, model=<pymc3.model.Model object>, random_seed=-1, live_plot=False, discard_tuned_samples=True, live_plot_kwargs=None, **kwargs={})
271 else:
272 sample_func = _sample
273
274 discard = tune if discard_tuned_samples else 0
275
--> 276 return sample_func(**sample_args)[discard:]
sample_func = <function _mp_sample>
sample_args = {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'njobs': 2, 'progressbar': True, 'random_seed': -1, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], ...}
discard = 500
277
278
279 def _sample(draws, step=None, start=None, trace=None, chain=0, tune=None,
280 progressbar=True, model=None, random_seed=-1, live_plot=False,
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _mp_sample(**kwargs={'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, 'tune': 500})
457 pbars = [kwargs.pop('progressbar')] + [False] * (njobs - 1)
458 traces = Parallel(n_jobs=njobs)(delayed(_sample)(chain=chains[i],
459 progressbar=pbars[i],
460 random_seed=rseed[i],
461 start=start_vals[i],
--> 462 **kwargs) for i in range(njobs))
kwargs = {'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, 'tune': 500}
njobs = 2
463 return merge_traces(traces)
464
465
466 def stop_tuning(step):
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=2), iterable=<generator object _mp_sample.<locals>.<genexpr>>)
784 if pre_dispatch == "all" or n_jobs == 1:
785 # The iterable was consumed all at once by the above for loop.
786 # No need to wait for async callbacks to trigger to
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=2)>
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time
792 self._print('Done %3i out of %3i | elapsed: %s finished',
793 (len(self._output), len(self._output),
---------------------------------------------------------------------------
Sub-process traceback:
---------------------------------------------------------------------------
ValueError Wed Jun 21 13:37:40 2017
PID: 12809 Python 3.5.2: /usr/bin/python3
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in __call__(self=<joblib.parallel.BatchedCalls object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(<function _sample>, (), {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...})]
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
126 def __init__(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func = <function _sample>
args = ()
kwargs = {'chain': 0, 'draws': 1000.0, 'live_plot': False, 'live_plot_kwargs': None, 'model': <pymc3.model.Model object>, 'progressbar': True, 'random_seed': 63967813, 'start': None, 'step': [<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], 'trace': None, ...}
132
133 def __len__(self):
134 return self._size
135
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws=1000.0, step=[<pymc3.step_methods.hmc.nuts.NUTS object>, <pymc3.step_methods.compound.CompoundStep object>], start=None, trace=None, chain=0, tune=500, progressbar=True, model=<pymc3.model.Model object>, random_seed=63967813, live_plot=False, live_plot_kwargs=None, **kwargs={})
286 tune, model, random_seed)
287 if progressbar:
288 sampling = tqdm(sampling, total=draws)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
it = undefined
strace = None
sampling = 0%| | 0/1000.0 [00:04<?, ?it/s]
292 if live_plot:
293 if live_plot_kwargs is None:
294 live_plot_kwargs = {}
295 if it >= skip_first:
...........................................................................
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self= 0%| | 0/1000.0 [00:04<?, ?it/s])
857 except AttributeError:
858 raise TqdmDeprecationWarning("""\
859 Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)`
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
obj = undefined
iterable = <generator object _iter_sample>
863 yield obj
864 # Update and print the progressbar.
865 # Note: does not call self.update(1) for speed optimisation.
866 n += 1
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws=1000, step=<pymc3.step_methods.compound.CompoundStep object>, start={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}, trace=None, chain=0, tune=500, model=<pymc3.model.Model object>, random_seed=63967813)
384 try:
385 for i in range(draws):
386 if i == tune:
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
states = undefined
step.step = <bound method CompoundStep.step of <pymc3.step_methods.compound.CompoundStep object>>
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
392 else:
393 strace.record(point)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self=<pymc3.step_methods.compound.CompoundStep object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
19 def step(self, point):
20 if self.generates_stats:
21 states = []
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
state = undefined
method.step = <bound method ArrayStepShared.step of <pymc3.step_methods.hmc.nuts.NUTS object>>
25 states.extend(state)
26 else:
27 point = method.step(point)
28 return point, states
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self=<pymc3.step_methods.hmc.nuts.NUTS object>, point={'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...})
147 share.set_value(point[var])
148
149 bij = DictToArrayBijection(self.ordering, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
apoint = undefined
stats = undefined
self.astep = <bound method NUTS.astep of <pymc3.step_methods.hmc.nuts.NUTS object>>
bij.map = <bound method DictToArrayBijection.map of <pymc3.blocking.DictToArrayBijection object>>
point = {'I_interval__': array([ 0.88891879, 0.88891879, 0.88891879, 0...9,
0.88891879, 0.88891879, 0.88891879]), 'S_interval__': array([ 0., 0., 0., 0., 0., 0., 0., 0., ... 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'Y': array([8982, 8982, 8982, 8982, 8982, 8982, 8982,...8982, 8982, 8982,
8982, 8982, 8982, 8982]), 'Yp': array([535, 535, 535, 535, 535, 535, 535, 535, 5... 535, 535, 535, 535, 535, 535, 535, 535, 535]), 'alpha_gamma_log__': array(6.04025463066055), 'beta_gamma_log__': array(-4.460857399439066), 'beta_interval__': array(-2.0621610464177564), 'gamma_log__': array(-1.9459101490553135), 'po_interval__': array(-2.3762728087852047), 'pp_interval__': array(0.0), ...}
153 return bij.rmap(apoint), stats
154 else:
155 apoint = self.astep(bij.map(point))
156 return bij.rmap(apoint)
...........................................................................
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self=<pymc3.step_methods.hmc.nuts.NUTS object>, q0=array([-2.37627281, 0. , 0. , 0... ,
-2.06216105, 0.32663426, 0. ]))
170 p0 = self.potential.random()
171 v0 = self.compute_velocity(p0)
172 start_energy = self.compute_energy(q0, p0)
173 if not np.isfinite(start_energy):
174 raise ValueError('Bad initial energy: %s. The model '
--> 175 'might be misspecified.' % start_energy)
start_energy = array(inf)
176
177 if not self.adapt_step_size:
178 step_size = self.step_size
179 elif self.tune:
ValueError: Bad initial energy: inf. The model might be misspecified.
___________________________________________________________________________
It was about that you were talking when you have set the testval?
Is the version I send earlier working for you now?
The problem is that if Yp is smaller than loss_shifted40, then the logp is -inf, as the number of observed values in a Binomial can't be larger than n. So the logp at the very first value is -inf. But since we need to compute gradients in NUTS, this can't work anymore. So NUTS throws an error.
By the way, it is easier to set njobs=1 while you are debugging. The error messages get much nicer to read. 🙂
Actually, it didn't work:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-43-d5e7d106faa4> in <module>()
3 # trace = pm.backends.text.load('trace')
4 # db = pm.backends.Text('trace')
----> 5 trace = pm.sample(5e2, njobs=1, progressbar=True)
6 # trace = pm.sample(5e4, njobs=2, step=[pm.HamiltonianMC(scaling=trace[-1]), pm.NUTS(scaling=trace[-1])], start=trace[-1], tune=1000, progressbar=True, trace=db)
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, nuts_kwargs, step_kwargs, progressbar, model, random_seed, live_plot, discard_tuned_samples, live_plot_kwargs, **kwargs)
274 discard = tune if discard_tuned_samples else 0
275
--> 276 return sample_func(**sample_args)[discard:]
277
278
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _sample(draws, step, start, trace, chain, tune, progressbar, model, random_seed, live_plot, live_plot_kwargs, **kwargs)
289 try:
290 strace = None
--> 291 for it, strace in enumerate(sampling):
292 if live_plot:
293 if live_plot_kwargs is None:
/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py in __iter__(self)
860 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
861
--> 862 for obj in iterable:
863 yield obj
864 # Update and print the progressbar.
/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py in _iter_sample(draws, step, start, trace, chain, tune, model, random_seed)
387 step = stop_tuning(step)
388 if step.generates_stats:
--> 389 point, states = step.step(point)
390 if strace.supports_sampler_stats:
391 strace.record(point, states)
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py in step(self, point)
22 for method in self.methods:
23 if method.generates_stats:
---> 24 point, state = method.step(point)
25 states.extend(state)
26 else:
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py in step(self, point)
150
151 if self.generates_stats:
--> 152 apoint, stats = self.astep(bij.map(point))
153 return bij.rmap(apoint), stats
154 else:
/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/hmc/nuts.py in astep(self, q0)
173 if not np.isfinite(start_energy):
174 raise ValueError('Bad initial energy: %s. The model '
--> 175 'might be misspecified.' % start_energy)
176
177 if not self.adapt_step_size:
ValueError: Bad initial energy: inf. The model might be misspecified.
Are you running the exact same thing I send you?
If you want to try the whole dataset you might need to replace the 300 by (loss_shifted40.max() + 10).
If this doesn't help try to uncomment some of the variables to figure out where the problem is and then set the testval to something reasonable. You need to make sure you don't have any values where
lower >= upperlower and uppern < 0 or observed >= nn < 0 or observed >= n@aseyboldt I already checked for these inconsistencies, as I told you, this model used work fine before I reinstall the packages, none change was applied.
Well, there isn't anything I can do about that. You didn't give me anything to go on there, and 3.0 is even obsolete at this point. The model you send clearly has issues, no matter what version of pymc3 you are using. All I can do here is try to help you to fix it, and to do that I need to know what you are actually doing. I vague "I checked for those inconsistencies" doesn't help.
So: What code are you executing, with what data, and what error message do you get. Also: What exactly happens when you run the exact code I send to you.
It works with the metropolis sampler, but for some reason it doesn't for NUTS. I'm not complaining about the new version, I'm sorry if I offended you because I really appreciate your help.
Yep, now it's fine, but I didn't figure out why is working only with Metropolis...
Don't worry, it's fine. 🙂
Just try to be more specific when you explain a problem. Debugging code without seeing that code is rather difficult. 😉
If Metropolis works but nuts doesn't then the easiest explanation would be that the initial logp is finite, but the gradient is not. You could check the output of those:
model.logp(model.test_point)
model.bijection.rmap(model.dlogp_array(model.dict_to_array(model.test_point)))
If either of those contains something that is inf or nan, than nuts can't get started.
is the inf or nan values in the model.logp(model.test_point) caused by the testval?
Yes, and you can set the start value or set different testval when you are declaring the RVs to avoid the Bad initial energy problem.
@marciomacielbastos Sorry for snapping at you like that yesterday. Reading it again today it sounds much more aggressive than I meant it. I was somewhat frustrated about unrelated stuff at the time and apparently you got a share of that. I hope I didn't scare you away, that certainly wasn't the intention.
@aseyboldt absolutely not my friend! In fact, you have been very helpful! I'm still crawling in probabilistic programming, and your help has been really valuable. I have many questions about pymc3, is there another channel (other than rising issues) to ask people like you, who have developed the package, on simple usage?
https://discourse.pymc.io/ is a good place!
On Thu, Jun 22, 2017 at 9:38 AM marciomacielbastos notifications@github.com
wrote:
@aseyboldt https://github.com/aseyboldt absolutely not my friend! In
fact, you've already been very helpful! I'm still crawling in probabilistic
programming, and your help has been really valuable. I have many questions
about pymc3, is there another channel (other than rising issues) to ask
people like you, who have developed the package, on simple usage?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/pymc-devs/pymc3/issues/2336#issuecomment-310382692,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACMHECDu0KSRE41yKeT9cCtEEmRiNHf7ks5sGm5WgaJpZM4OAV6H
.
@marciomacielbastos Good to hear 😄
Yes, discourse is the preferred place for general questions.
Most helpful comment
Don't worry, it's fine. 🙂
Just try to be more specific when you explain a problem. Debugging code without seeing that code is rather difficult. 😉
If Metropolis works but nuts doesn't then the easiest explanation would be that the initial logp is finite, but the gradient is not. You could check the output of those:
If either of those contains something that is inf or nan, than nuts can't get started.