I'm using a pymc model that contains the special function gamma. Since scipy special functions doesn't work with pytensor as variable, I'm trying to escape the problem with an @as_op:
@as_op(itypes=theano.tensor.dscalar, otypes=theano.tensor.dscalar)
def gamma_theano(x):
return scipy.special.gamma(x)
This very naive solution was used to work perfectly with previous projects (and previous package versions), while now I'm getting the error:
TypeError: We expected inputs of types '[TensorType(float64, scalar)]' but got types '[TensorType(float64, ())]'
Suggestions are very well received. Thanks.
Using pytensor instead of theano resolves the error:
import pytensor
@as_op(itypes=pytensor.tensor.dscalar, otypes=pytensor.tensor.dscalar)
def gamma_theano(x):
return scipy.special.gamma(x)
However, in my case, this didn't solved the issue because it led to a segmentation error.
I've found the solution with the built-in gamma function of pytensor:
import pytensor
pytensor.tensor.math.gamma(x)