← Questions

Vectorized nearest-neighbour classifier as a linear layer

0
OpenAIMetaCodingLast asked Sep 2026

Implement a 1-nearest-neighbour classifier in NumPy with no Python loops. Then rewrite it as the forward pass of a small network, a matrix product plus a bias followed by an activation, and explain why the two give the same predictions.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding