# ValueError: Unexpected type in draw\_value: \<class 'theano.gof.graph.Constant'\>

**URL:** <https://discourse.pymc.io/t/valueerror-unexpected-type-in-draw-value-class-theano-gof-graph-constant/3750>\
**Category:** Questions\
**Created:** [August 20, 2019, 4:24pm UTC](https://discourse.pymc.io/t/valueerror-unexpected-type-in-draw-value-class-theano-gof-graph-constant/3750 "2019-08-20T16:24:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdyetton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/bdyetton/32/208_2.png) [@bdyetton](https://discourse.pymc.io/u/bdyetton)\
**Post date:** [August 20, 2019, 4:24pm UTC](https://discourse.pymc.io/t/valueerror-unexpected-type-in-draw-value-class-theano-gof-graph-constant/3750/1 "2019-08-20T16:24:36Z")

</div>

Hi Pymc3 Comunity,  
I’m posting this question here as well as rasing it as an issue on [Github](https://github.com/pymc-devs/pymc3/issues/3595), in case someone here has seen something similar.

I get the above error when sampling from the posterior predictive.

It appears that somewhere in the theano graph a theano.NoneConst is being created, and sample\_posterior\_predictive throws an error when it tries to sample from it.

In the example model below, the ANOVA type model has a mean for each group, where each group is defined by 2 factors (x and g). Both g and x are used to pick a specific group mean parameter which the DV (y) is then sampled from. Here im modeling a single DV, but i’d like to extend it to model 2 DV, so my parameters have a dimention for the output.

I think this is something to do with funny broadcasting, because when I don’t include the y dimension in my parameters, there is no issue (see note in code).

The example:

```python
    #create some data
    n_d = 500
    n_x = 2
    n_g = 10
    g = np.random.randint(0, n_g, (n_d,)) # group
    x = np.random.randint(0, n_x, (n_d,)) # x factor
    true_x_effect = np.random.normal(0, 10, (n_x,))
    true_g_effect = np.random.normal(0, 10, (n_g,))
    y = np.random.normal(true_x_effect[x]+true_g_effect[g], 1)
    data = pd.DataFrame({'x':x, 'y1':y, 'g':g})
    y_vars = ['y1']
    n_y = len(y_vars)

    with pm.Model() as model:
        multi_dim_rv = pm.Normal('multi_dim_rv', mu=0, sd=1, shape=(n_x, n_g, n_y))
        indexed_rv = multi_dim_rv[data['x'], data['g'], :] #if : is replaced by 0 (effectivly removing y dimention), this works fine
        error = pm.HalfCauchy('error', 10)
        obs_data = data[y_vars].values
        obs = pm.Normal('obs', mu=indexed_rv, sd=error, observed=obs_data)
        print('dist_shape', obs.distribution.logp(data[y_vars].values).tag.test_value.shape) #shapes seem ok
        print('data_shape', obs_data.shape) #shapes seem ok
        trace = pm.sample() #samples fine.
        pm.sample_posterior_predictive(trace) #NoneConst error here.

```

Trace:

```python
Traceback (most recent call last):
  File "/home/bdyetton/PSleep/src/modeling/run_models.py", line 323, in <module>
    test_ppc_issue()
  File "/home/bdyetton/PSleep/src/modeling/run_models.py", line 282, in test_ppc_issue
    pm.sample_posterior_predictive(trace) #NoneConst error here.
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/sampling.py", line 1167, in sample_posterior_predictive
    values = draw_values(vars, point=param, size=size)
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 627, in draw_values
    size=size)
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 817, in _draw_value
    size=None))
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/continuous.py", line 495, in random
    point=point, size=size)
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 627, in draw_values
    size=size)
  File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 851, in _draw_value
    raise ValueError('Unexpected type in draw_value: %s' % type(param))
ValueError: Unexpected type in draw_value: <class 'theano.gof.graph.Constant'>

```

Has anyone hit something like this before?

## Versions and main components

- PyMC3 Version: Master (8/18/19)
- Theano Version: 1.0.4
- Python Version: 3.7
- Operating system: Windows 10
- How did you install PyMC3: pip

---

<div class="post-metadata">

**Author:** ![bdyetton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/bdyetton/32/208_2.png) [@bdyetton](https://discourse.pymc.io/u/bdyetton)\
**Post date:** [August 21, 2019, 5:47pm UTC](https://discourse.pymc.io/t/valueerror-unexpected-type-in-draw-value-class-theano-gof-graph-constant/3750/2 "2019-08-21T17:47:19Z")

</div>

This was a bug. See [Github](https://github.com/pymc-devs/pymc3/issues/3595).
