I applied this change:
n = 1000
with pymc3.Model() as model:
# On
pOn = pymc3.Beta('pOn', alpha=on_count, beta=(schema_count - on_count))
on = pymc3.Bernoulli('on', p=pOn, dtype="int64")
# Triangle
triangle_mixture_weights = [on, (1. - on)]
tri_giv_on = pymc3.Bernoulli.dist(pTri_given_not_on + tri_delta_on)
tri_giv_not_on = pymc3.Bernoulli.dist(pTri_given_not_on)
triangle = pymc3.Mixture('triangle', w=triangle_mixture_weights, \
comp_dists=[tri_giv_on, tri_giv_not_on], \
shape=2)
res = pymc3.sample(n)
I receive the following error:
Multiprocess sampling (2 chains in 2 jobs)
CompoundStep
>NUTS: [pOn, pos]
>Metropolis: [triangle]
>BinaryGibbsMetropolis: [on]
Sampling 2 chains: 0%| | 0/3000 [00:00<?, ?draws/s]
pymc3.parallel_sampling.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 903, in __call__
self.fn() if output_subset is None else\
TypeError: expected type_num 5 (NPY_INT32) got 7
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pymc3/parallel_sampling.py", line 110, in run
self._start_loop()
File "/usr/local/lib/python3.5/dist-packages/pymc3/parallel_sampling.py", line 160, in _start_loop
point, stats = self._compute_point()
File "/usr/local/lib/python3.5/dist-packages/pymc3/parallel_sampling.py", line 191, in _compute_point
point, stats = self._step_method.step(self._point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/compound.py", line 27, in step
point, state = method.step(point)
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/arraystep.py", line 175, in step
apoint, stats = self.astep(self.bij.map(point))
File "/usr/local/lib/python3.5/dist-packages/pymc3/step_methods/metropolis.py", line 162, in astep
accept = self.delta_logp(q, q0)
File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 917, 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 903, in __call__
self.fn() if output_subset is None else\
TypeError: expected type_num 5 (NPY_INT32) got 7
Apply node that caused the error: Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}(InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of 0}, TensorConstant{(1, 1) of 1})
Toposort index: 22
Inputs types: [TensorType(int32, col), TensorType(int8, (True, True)), TensorType(int8, (True, True))]
Inputs shapes: [(2, 1), (1, 1), (1, 1)]
Inputs strides: [(8, 8), (1, 1), (1, 1)]
Inputs values: [array([[2],
[4]]), array([[0]], dtype=int8), array([[1]], dtype=int8)]
Outputs clients: [[Elemwise{Composite{Switch(i0, Switch(i1, i2, i3), i4)}}(Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}.0, InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of 0.0}, TensorConstant{(1, 1) of -inf}, TensorConstant{(1, 1) of -inf}), Elemwise{Composite{Switch(i0, Switch(i1, i2, i3), i4)}}(Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}.0, InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of ..4393873245}, TensorConstant{(1, 1) of ..2804325936}, TensorConstant{(1, 1) of -inf})]]
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:
TypeError: expected type_num 5 (NPY_INT32) got 7
Apply node that caused the error: Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}(InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of 0}, TensorConstant{(1, 1) of 1})
Toposort index: 22
Inputs types: [TensorType(int32, col), TensorType(int8, (True, True)), TensorType(int8, (True, True))]
Inputs shapes: [(2, 1), (1, 1), (1, 1)]
Inputs strides: [(8, 8), (1, 1), (1, 1)]
Inputs values: [array([[2],
[4]]), array([[0]], dtype=int8), array([[1]], dtype=int8)]
Outputs clients: [[Elemwise{Composite{Switch(i0, Switch(i1, i2, i3), i4)}}(Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}.0, InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of 0.0}, TensorConstant{(1, 1) of -inf}, TensorConstant{(1, 1) of -inf}), Elemwise{Composite{Switch(i0, Switch(i1, i2, i3), i4)}}(Elemwise{Composite{Cast{int8}((GE(i0, i1) * LE(i0, i2)))}}.0, InplaceDimShuffle{0,x}.0, TensorConstant{(1, 1) of ..4393873245}, TensorConstant{(1, 1) of ..2804325936}, TensorConstant{(1, 1) of -inf})]]
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:
Traceback (most recent call last):
File "test.py", line 114, in <module>
res = pymc3.sample(n)
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 432, in sample
trace = _mp_sample(**sample_args)
File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 965, in _mp_sample
for draw in sampler:
File "/usr/local/lib/python3.5/dist-packages/pymc3/parallel_sampling.py", line 393, in __iter__
draw = ProcessAdapter.recv_draw(self._active)
File "/usr/local/lib/python3.5/dist-packages/pymc3/parallel_sampling.py", line 297, in recv_draw
raise error from old_error
RuntimeError: Chain 1 failed.