Closed
Description
Description
These calls make inputs that are valid tensor_like
fail:
import pymc as pm
with pm.Model() as m:
x = pm.Normal("x")
y = pm.Beta("y", [x+1, x-1], 1) # Fails
y = pm.Beta("y", pm.math.stack([x+1, x-1]), 1) # works
TypeError: float() argument must be a string or a real number, not 'TensorVariable'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ricardo/.conda/envs/pymc-experimental/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3505, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-9eb4432272c4>", line 5, in <module>
y = pm.Beta("y", [x+1, x-1], 1)
File "/home/ricardo/.conda/envs/pymc-experimental/lib/python3.10/site-packages/pymc/distributions/distribution.py", line 310, in __new__
rv_out = cls.dist(*args, **kwargs)
File "/home/ricardo/.conda/envs/pymc-experimental/lib/python3.10/site-packages/pymc/distributions/continuous.py", line 1142, in dist
alpha = pt.as_tensor_variable(floatX(alpha))
File "/home/ricardo/.conda/envs/pymc-experimental/lib/python3.10/site-packages/pymc/pytensorf.py", line 439, in floatX
return np.asarray(X, dtype=pytensor.config.floatX)
ValueError: setting an array element with a sequence.
PyTensor has a builtin mechanism to control the promotion of inputs to float that should be accessible to users.