I have to implement the L2 distance, which has the geometric interpretation of computing the euclidean distance between two vectors. The distance takes the form:

$$d_2(I_1,I_2)=sqrt{sum_{p} left( I^p_1 – I^p_2 right)^2}$$

If $I_1$ has a size of `(50000 x 3072)`

and $I_2$ a size of `(3072)`

.

I have to implement that distance using Python with Numpy, and I don’t have to use loops. I have to do it using only multiplication and two broadcasting sums.

My problem is that I don’t know how multiplication and broadcasting sums can do it. Maybe using $I_2$ transpose and multiply it to $I_1$, but I’m only guessing.

Is there a way to get `L2 distance`

using matrix multiplication?