# Model yeilding no samples

**URL:** <https://discourse.pymc.io/t/model-yeilding-no-samples/1625>\
**Category:** Questions\
**Created:** [July 31, 2018, 9:01pm UTC](https://discourse.pymc.io/t/model-yeilding-no-samples/1625 "2018-07-31T21:01:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaddamanil16](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gaddamanil16/32/927_2.png) [@gaddamanil16](https://discourse.pymc.io/u/gaddamanil16)\
**Post date:** [July 31, 2018, 9:01pm UTC](https://discourse.pymc.io/t/model-yeilding-no-samples/1625/1 "2018-07-31T21:01:05Z")

</div>

I am implementing Mixed membsership stochastic block model with pymc3. I have managed to define the model. There is no compilation error. But after sampling when I plot it it gives blank and weird plots.

Can someone please help .

```
import numpy as np
import pymc3 as pm
import theano.tensor as tt
user_data = np.array([[1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0],
[1,0,1,0,0,1,0,0,1,1,1,0,0,0,0,0,1,0,1,0],
[0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0],
[0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0],
[1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1],
[0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0],
[0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0],
[1,1,0,0,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0],
[0,1,0,0,1,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0],
[1,0,1,0,0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0],
[0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,1,0,0],
[1,0,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0],
[0,1,1,0,0,1,0,0,0,1,0,0,1,0,0,1,1,0,0,0],
[0,0,1,0,0,0,1,1,0,1,1,0,0,1,0,0,1,0,1,1],
[1,1,0,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,1,0],
[1,0,0,1,1,1,0,0,0,0,0,0,1,1,0,1,0,0,0,1]])

(people,val) = user_data.shape
user_data_vector = user_data.reshape(people*people,1).T

K = 3 #Number of communities
alpha = np.ones((K)) 
model = pm.Model()

B = tt.ones((K,K))*0.8 #np.eye(K)*0.8 #interaction between different communities
with model:
   
    pi_list = pm.Dirichlet('userx_pi', a=alpha, shape = (people, K))
        
    z_aTb = pm.Categorical('a_' ,p = pi_list, shape =(people*K,people))
    
    z_aTb_re = tt.reshape(z_aTb,(people,people,K))

    bernoulli_params = tt.tensordot(tt.tensordot(z_aTb_re,B,axes = 1),z_aTb_re.T, axes = 2) 
    
    bernoulli_params = tt.reshape(bernoulli_params,(1,people*people)) 
with model:
    y = pm.Bernoulli('y', p=bernoulli_params , observed = user_data_vector)       

with model:
    step1 = pm.Metropolis()
    tr = pm.sample(1000, step =step1,chains =1)
with model:
    pm.plots.traceplot(tr,['userx_pi']);
```

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [July 31, 2018, 9:19pm UTC](https://discourse.pymc.io/t/model-yeilding-no-samples/1625/2 "2018-07-31T21:19:06Z")

</div>

Likely your MCMC chain is completely stuck and there is no sample accepted.  
High dimension discrete parameters like below are very difficult to sample:

```python
z_aTb = pm.Categorical('a_' ,p = pi_list, shape =(people*K,people))

```

You should consider rewriting your model into a marginalized mixture model.
