must be real number, not TensorVariable

297 views Asked by At

My code is:

h = pm.Normal("h", mu=0.0, sigma=0.1)
a = pm.Normal("a", mu=mu_a, sigma=tau_a, dims="h")
d = pm.Normal("d", mu=mu_d, sigma=tau_d, dims="a") 
theta_1 = math.exp(h + a + d)
error:
---> 14 theta_1 = math.exp(a + d)

TypeError: must be real number, not TensorVariable
1

There are 1 answers

0
jtlz2 On

Unforunately python's builtin math library doesn't support theano tensors. So you need to follow https://discourse.pymc.io/t/error-in-basic-model-due-to-trigonometric-functions-using-math-library/2825/2 in using pymc3.math.... or theano.tensor (for example).

I am having the same problem in needing to pymc3-ize a custom function.

HTH