Pm.math or theano for trigonometric functions

Dear All,
I have quite a long model which I am trying to use in Pymc3 model and so far couldn’t succeed. Most part of the model involves arithmetic but some part also have trigonometric functions. If I use it same I have written using numpy, I got following error most of the time:

raise AsTensorError("Cannot convert %s to TensorType" % str_x, type(x))

AsTensorError: ('Cannot convert [Elemwise{add,no_inplace}.0 Elemwise{add,no_inplace}.0\n Elemwise{add,no_inplace}.0] to TensorType', <class 'numpy.ndarray'>)

Can you please suggest me to replace following lines in order to let them work in pymc3 model. If it is required I can also send my code and data to you.


p=np.array([[np.cos(np.radians(A)), -np.sin(np.radians(A)), 0],\
      [np.sin(np.radians(A)), np.cos(np.radians(A)),0],\
      [0, 0, 1]])

x1 = new_x[0,:]
x2 = new_x[1,:]
x3 = new_x[2,:]


q = np.arctan(a1) + np.log(a2)



Replace numpy functions with theano functions. For example, replace numpy.cos with theano.tensor.cos. See more here

1 Like