Friday 15 August 2014

matrix - A Pure Pythonic Pairwise Euclidean distance of rows of a numpy ndarray -



matrix - A Pure Pythonic Pairwise Euclidean distance of rows of a numpy ndarray -

i have matrix of size (n_classes, n_features) , want compute pairwise euclidean distance of each pair of classes output (n_classes, n_classes) matrix each cell has value of euclidean_distance(class_i, class_j).

i know there scipy spatial distances (http://docs.scipy.org/doc/scipy-0.14.0/reference/spatial.distance.html) , sklearn.metric.euclidean distances (http://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.euclidean_distances.html) want utilize in theano software need pure mathematical formula rather functions compute results.

for illustration need series of transformations = x * b, d = x.t-x, results = d.t contains matrix mathematical operations not functions.

you can using numpy broadcasting shown in this gist. should straightforward convert theano code, or reference @eickenberg's comment above, since he's 1 showed me how this!

numpy matrix euclidean-distance theano

No comments:

Post a Comment