Pinterest-inspired visual retrieval prototype compares a batch of item embeddings against every other item in the batch. You need to compute the pairwise squared-distance matrix efficiently and with the expected shape.
Compute the matrix of squared Euclidean distances between all pairs of rows of X: entry (i,j) is ∥xi−xj∥2.
Implement solve(X).
Returns. Return a symmetric n×n float NumPy matrix with zeros on the diagonal.
Example 1
Input:
solve([[0, 0], [3, 4]])
Output:
[[0.0, 25.0], [25.0, 0.0]]
Example 2
Input:
solve([[1.0], [2.0], [4.0]])
Output:
[[0.0, 1.0, 9.0], [1.0, 0.0, 4.0], [9.0, 4.0, 0.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.