I would like to add values into a tensor which should be of dimension for e.g
(3,2,3) . If I want to add values in that tensor how can I do it.
I have :
for a_person in range(1):
for b_person in range(1):
z_aTb[a_person,b_person] = pm.Categorical('ax_%dT%d' %(a_person,b_person),p = pi_list[a_person], shape =(1,K))
Instead of using for loop I want to rewrite it in such a way that the computation time improves. The dimension I gave as example is for
Help much appreciated.
Dealing with shape in Categorical is quite tricky. I suggest you to create a RV with the shape
(3*2*3), with a
p=(3*2*3, k), then reshape it into the shape you want.
If I do so won’t the resulting tensor be of shape(3,2,3).
Ops the post was rendered different than I expected, see edited post above.
p I can’t just simply use
p=(3*2*3, k) because p has to be from
pi_list = np.empty(people,dtype=object)
for user in range(people):
user_pi = pm.Dirichlet('userx_pi_%d' % user, a=alpha, shape = (1,K))
pi_list[user] = user_pi
So I tried something like this :
alpha = np.ones((K*people))
pi_list = pm.Dirichlet('userx_pi', a=alpha, shape = (K*people))
pi_list = tt.reshape(pi_list,(people,K))
I dont think that’s right, you should do:
alpha = np.ones((K))
pi_list = pm.Dirichlet('userx_pi', a=alpha, shape = (people, K))
What exactly should be the dimensions of p in case of Categorical?
Because if I use
z_aTb = pm.Categorical('a_' ,p = pi_list, shape =(people*K*people)) with p as
pi_list then its shape is
people, K whereas shape is way bigger.
in the case of Categorical, if the p is shape
(n, k) with
k being the number of categories, the output random variable has the shape
I would like to multiply
z_aTb.T . and reshape it into
1,people*people . I think I’m doing some silly mistake here.
B = np.eye(K)*0.8
z_aTb = pm.Categorical('a_' ,p = pi_list, shape =(people*K,people))
bernoulli_params = tt.dot(tt.dot(z_aTb,B),z_aTb.T)
bernoulli_params = tt.reshape(bernoulli_params,(1,people*people))
Is there any way I can use theano dot and multiply
tt.dot(tt.dot(z_aTb,B),z_aTb.T) ? Because there will be dimension error this way!
@junpenglao For e.g I have tensors with shape as
(20,3,20) (3,3) (20,3,20) . Multiplying these I would like to get output result shape as
(400,) . How can I achieve it?