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.

1.

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]])
temp_1=np.asarray([x0,y0,z0])

new_x= xrot.dot(temp_1)
x1 = new_x[0,:]
x2 = new_x[1,:]
x3 = new_x[2,:]

2.

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

3.

U1=np.array([AX,AY,AZ])
U2=xrot.transpose().dot(U1)

Replace numpy functions with theano functions. For example, replace numpy.cos with theano.tensor.cos. See more here http://deeplearning.net/software/theano/tutorial/index.html#tutorial

1 Like