Hello! I’m new to this package.
While trying to assembly my model, I encountered the error.
I have no idea what’s going on and what to do with this error.
The code and error message as following:
M, E = data.shape
K = 3
a0 = np.ones(K)
alpha0 = 1
beta0 = 1
lower = 5
upper = 20
model = pm.Model()
with model:
theta = pm.Dirichlet("theta", a=a0, testval=np.ones(K)/K)
psi1 = [pm.Beta("psi_{}".format(k), alpha=alpha0, beta=beta0, shape=E) for k in range(K)]
mu1 = [pm.Beta("mu_{}".format(k), alpha=alpha0, beta=beta0, shape=E) for k in range(K)]
alpha1 = [pm.DiscreteUniform("alpha_{}".format(k), lower=lower, upper=upper, shape=E) for k in range(K)]
stacked_psi1 = tt.stack(psi1)
stacked_mu1 = tt.stack(mu1)
stacked_alpha1 = tt.stack(alpha1)
z = pm.Categorical("components", p=theta, shape=(M,))
expr = pm.ZeroInflatedNegativeBinomial("expr", psi=stacked_psi1[z], mu=stacked_mu1[z], alpha=stacked_alpha1[z], observed=data)
with model:
step1 = pm.Metropolis(vars=[theta, stacked_psi1, stacked_mu1, stacked_alpha1])
step2 = pm.CategoricalGibbsMetropolis(vars=[z])
tr = pm.sample(1000, step=[step1, step2])
Error message:
Multiprocess sampling (2 chains in 2 jobs)
CompoundStep
>CompoundStep
>>Metropolis: [alpha_0]
>>Metropolis: [alpha_1]
>>Metropolis: [alpha_2]
>>Metropolis: [mu_0_logodds__]
>>Metropolis: [mu_1_logodds__]
>>Metropolis: [mu_2_logodds__]
>>Metropolis: [psi_0_logodds__]
>>Metropolis: [psi_1_logodds__]
>>Metropolis: [psi_2_logodds__]
>>Metropolis: [theta_stickbreaking__]
>CategoricalGibbsMetropolis: [components]
Process ForkPoolWorker-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.6/multiprocessing/pool.py", line 108, in worker
task = get()
File "/usr/lib/python3.6/site-packages/joblib/pool.py", line 362, in get
return recv()
File "/usr/lib/python3.6/multiprocessing/connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "/usr/lib/python3.6/site-packages/theano/compile/function_module.py", line 1082, in _constructor_Function
f = maker.create(input_storage, trustme=True)
File "/usr/lib/python3.6/site-packages/theano/compile/function_module.py", line 1715, in create
input_storage=input_storage_lists, storage_map=storage_map)
File "/usr/lib/python3.6/site-packages/theano/gof/link.py", line 699, in make_thunk
storage_map=storage_map)[:3]
File "/usr/lib/python3.6/site-packages/theano/gof/vm.py", line 1084, in make_all
impl=impl))
File "/usr/lib/python3.6/site-packages/theano/gof/op.py", line 955, in make_thunk
no_recycling)
File "/usr/lib/python3.6/site-packages/theano/gof/op.py", line 833, in make_c_thunk
e = FunctionGraph(node.inputs, node.outputs)
File "/usr/lib/python3.6/site-packages/theano/gof/fg.py", line 137, in __init__
inputs, outputs = graph.clone(inputs, outputs)
File "/usr/lib/python3.6/site-packages/theano/gof/graph.py", line 862, in clone
equiv = clone_get_equiv(i, o, copy_inputs, copy_orphans)
File "/usr/lib/python3.6/site-packages/theano/gof/graph.py", line 899, in clone_get_equiv
cpy = input.clone()
File "/usr/lib/python3.6/site-packages/theano/gof/graph.py", line 607, in clone
cp = self.__class__(self.type, self.data, self.name)
File "/usr/lib/python3.6/site-packages/theano/tensor/var.py", line 961, in __init__
Constant.__init__(self, type, data, name)
File "/usr/lib/python3.6/site-packages/theano/gof/graph.py", line 579, in __init__
self.data = type.filter(data)
File "/usr/lib/python3.6/site-packages/theano/tensor/type.py", line 189, in filter
"object dtype", data.dtype)
TypeError: ('The following error happened while compiling the node', Elemwise{Composite{Switch((EQ(i0, i1) * i2), i1, Switch(Cast{int8}(GE(i0, i1)), ((Switch(EQ(i0, i1), i3, (i4 * log(i0))) - i5) - i0), i3))}}(AdvancedSubtensor1.0, TensorConstant{(1, 1) of 0}, TensorConstant{[[ True Fa..ue True]]}, TensorConstant{(1, 1) of -inf}, TensorConstant{[[0. 3. 0...0. 0. 0.]]}, TensorConstant{[[0. .. ]]}), '\n', 'The numpy.ndarray object is not aligned. Theano C code does not support that.', 'object buffer<memory at 0x7f34b57c6990>', 'object shape', (54, 7873), 'object strides', (62984, 8), 'object dtype', dtype('float64'))
...
- PyMC3 Version: 3.3
- Theano Version: 1.0.0
- Python Version: 3.6.4
- Operating system: Arch Linux
- How did you install PyMC3: yaourt