Closed fonnesbeck closed 5 years ago
I have similar problem here:
bounded = pm.Bound(pm.Normal, lower=0., upper=1.)
out = bounded('out', mu=prediction, sd=sigma, observed=ann_output)
Is there a way to overcome this?
That example seems only to have a scalar bound. Shouldn't be a problem.
Here's a full error:
74
75 # Binary classification -> Bernoulli likelihood
---> 76 out = bounded('out', mu=prediction, sd=sigma, observed=ann_output)
77
78 return out
/usr/local/lib/python2.7/dist-packages/pymc3/distributions/distribution.pyc in __call__(self, *args, **kwargs)
476
477 return Bounded(first, self.distribution, self.lower, self.upper,
--> 478 *args, **kwargs)
479
480 def dist(self, *args, **kwargs):
/usr/local/lib/python2.7/dist-packages/pymc3/distributions/distribution.pyc in __new__(cls, name, *args, **kwargs)
32 data = kwargs.pop('observed', None)
33 total_size = kwargs.pop('total_size', None)
---> 34 dist = cls.dist(*args, **kwargs)
35 return model.Var(name, dist, data, total_size)
36 else:
/usr/local/lib/python2.7/dist-packages/pymc3/distributions/distribution.pyc in dist(cls, *args, **kwargs)
43 def dist(cls, *args, **kwargs):
44 dist = object.__new__(cls)
---> 45 dist.__init__(*args, **kwargs)
46 return dist
47
/usr/local/lib/python2.7/dist-packages/pymc3/distributions/distribution.pyc in __init__(self, distribution, lower, upper, transform, *args, **kwargs)
408 if not np.isinf(lower) and not np.isinf(upper):
409 self.transform = transforms.interval(lower, upper)
--> 410 if default <= lower or default >= upper:
411 self.testval = 0.5 * (upper + lower)
412
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
The automatic transformation of bounded variables to an unconstrained support needs to be generalized to support vector-valued variables with different bounds among the elements of the variable. This comes up in situations like this:
This is a survival model, so each element of the data array is constrained below by the censoring time, which varies for each element of
day_masked
. However, when this is run:Clearly, the transformation was not engineered to handle this. This should hopefully be easy to accommodate.