Skip to content

Error computing test_value for transformed dist #2258

@junpenglao

Description

@junpenglao
import pymc3 as pm
with pm.Model() as model:
    a1 = pm.Uniform('a1', lower=0., upper=1.)
    b1 = pm.Uniform('b1', lower=0., upper=1. - a1)
    pm.sample(1000)

raise:

Traceback (most recent call last):

  File "<ipython-input-1-e7f2b743f1a1>", line 5, in <module>
    pm.sample(1000)

  File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 273, in sample
    return sample_func(**sample_args)[discard:]

  File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 288, in _sample
    for it, strace in enumerate(sampling):

  File "/usr/local/lib/python3.5/dist-packages/tqdm/_tqdm.py", line 862, in __iter__
    for obj in iterable:

  File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 367, in _iter_sample
    _update_start_vals(start, model.test_point, model)

  File "/usr/local/lib/python3.5/dist-packages/pymc3/sampling.py", line 483, in _update_start_vals
    b[tname] = transform_func[0].forward(a[name]).eval()

  File "/usr/local/lib/python3.5/dist-packages/theano/gof/graph.py", line 516, in eval
    self._fn_cache[inputs] = theano.function(inputs, self)

  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function.py", line 326, in function
    output_keys=output_keys)

  File "/usr/local/lib/python3.5/dist-packages/theano/compile/pfunc.py", line 486, in pfunc
    output_keys=output_keys)

  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 1807, in orig_function
    output_keys=output_keys).create(

  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 1446, in __init__
    accept_inplace)

  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 177, in std_fgraph
    update_mapping=update_mapping)

  File "/usr/local/lib/python3.5/dist-packages/theano/gof/fg.py", line 174, in __init__
    self.__import_r__(output, reason="init")

  File "/usr/local/lib/python3.5/dist-packages/theano/gof/fg.py", line 345, in __import_r__
    self.__import__(variable.owner, reason=reason)

  File "/usr/local/lib/python3.5/dist-packages/theano/gof/fg.py", line 390, in __import__
    raise MissingInputError(error_msg, variable=r)

MissingInputError: Input 0 of the graph (indices start from 0), used to compute sigmoid(a1_interval__), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.

Diagnostic:
Error is from the https://github.com/pymc-devs/pymc3/blob/master/pymc3/sampling.py#L483

for example:

from pymc3.util import is_transformed_name, get_untransformed_name
def update_start_vals(a, b, model):
    """Update a with b, without overwriting existing keys. Values specified for
    transformed variables on the original scale are also transformed and inserted.
    """
    for name in a:
        for tname in b:
            if is_transformed_name(tname) and get_untransformed_name(tname) == name:
                transform_func = [d.transformation for d in model.deterministics if d.name == name]
                if transform_func:
                    b[tname] = transform_func[0].forward(a[name]).eval()

    a.update({k: v for k, v in b.items() if k not in a})

a = {'a1': .5, 'b1':.7}
b = model.test_point
update_start_vals(a, b, model)

gives the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions