Error with sample_prior_predictive


#1

Hi all,

I’m receiving the following error when using sample_prior_predictive on a particular model:

Traceback (most recent call last):
  File "prior_pred.py", line 50, in <module>
    sample()
  File "prior_pred.py", line 22, in sample
    random_seed=conf.prior_pred_seed
  File "/home/damien/venv/scene_illum/lib/python2.7/site-packages/pymc3/sampling.py", line 1316, in sample_prior_predictive
    values = draw_values([model[name] for name in names], size=samples)
  File "/home/damien/venv/scene_illum/lib/python2.7/site-packages/pymc3/distributions/distribution.py", line 321, in draw_values
    evaluated[param_idx] = _draw_value(param, point=point, givens=givens.values(), size=size)
  File "/home/damien/venv/scene_illum/lib/python2.7/site-packages/pymc3/distributions/distribution.py", line 414, in _draw_value
    if size and values and not all(var.dshape == val.shape for var, val in zip(variables, values)):
  File "/home/damien/venv/scene_illum/lib/python2.7/site-packages/pymc3/distributions/distribution.py", line 414, in <genexpr>
    if size and values and not all(var.dshape == val.shape for var, val in zip(variables, values)):
AttributeError: 'TensorVariable' object has no attribute 'dshape'

The problem seems to be that there are items in variables that are of type TensorVariable, which do not have the dshape attribute. Often this isn’t a problem because the all stops as soon as it receives a False and the TensorVariable items don’t get tested - but in the particular instance that is causing the error, the first item in variables is a TensorVariable.

I haven’t been able to pin it down to create a minimal working example - let me know if it would be helpful to see the complete (rather unwieldy) model.

Thanks!


#2

There is a pretty big change going on currently for draw_values (which sample_prior_prdicitive directly use): https://github.com/pymc-devs/pymc3/pull/3214 hopefully this will be fixed as well (will check back when the PR is merged.)


#3

Great, thanks - I will keep an eye on that PR and hopefully it will fix it.