theano: summation by class label
问题 I have a matrix which represents a distances to the k-nearest neighbour of a set of points, and there is a matrix of class labels of the nearest neighbours. (both N-by-k matrix) What is the best way in theano to build a (N-by-#classes) matrix whose (i,j) element will be the sum of distances from i-th point to its k-NN points with the class label 'j'? Example: # N = 2 # k = 5 # number of classes = 3 K_val = [[1,2,3,4,6], [2,4,5,5,7]] l_val = [[0,1,2,0,1], [2,0,1,2,0]] result = [[5,8,3], [11,5