I want to generate a symmetric matrix called K. At some given locations of this matrix, the elements are parameters kij drawn from normal distributions; at other locations, the elements are 0. The uploaded file “adjacent_half_binary.csv” is an upper triangular matrix. It has the same size as matrix K. This upper triangular matrix tells us the locations where the symmetric matrix K contains parameters. Specifically, the “adjacent_half_binary.csv” contains 0 and 1. The locations with 1 are the locations that contain parameters and the locations with 0 contain 0. Below is part of my code used to generate such kind of symmetric matrix with the use of the given upper triangular matrix. However, when I used the obtained K to do further calculations, I obtain the following error:
TypeError: Tensor type field must be a TensorType; found <class ‘theano.graph.type.Generic’>.
Therefore, I think my way to generate the symmetric matrix K is not correct. Could you please provide some advice? Thank you so much!
adjacent_half_binary.csv (14.3 KB)
with pm.Model() as model: BoundedNormal_k = pm.Bound(pm.Normal, lower = 0) n_ks = np.sum(np.sum(connectome_hcp_half_binary)) ks =  for i in range(n_ks): ks.append(BoundedNormal_k('k'+str(i+1),0,0.5)) k_loc = np.array(adjacent_half_binary).reshape(-1) K_half_vec =  j = 0 for i in range(len(k_loc)): if k_loc[i] == 1: K_half_vec.append(ks[j]) j = j + 1 else: K_half_vec.append(0) K_half = np.array(K_half_vec).reshape((84,84)) K = K_half.T + K_half- np.diag(np.diag(K_half)) K = theano.shared(K)