← Questions
Nearest-center assignment without an N x K x D distance tensor
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Given N points and K centers in D dimensions, assign each point to its nearest center, as in the assignment step of k-means. The obvious broadcast builds an N x K x D array of differences, which runs out of memory at scale. Rewrite it so it never builds that array (for example by expanding the squared distance into dot products, or by working in chunks), and discuss memory, speed and numerical accuracy.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
