NumPy Broadcasting: Calculating sum of squared differences between two arrays
<p>I have the following code.  It is taking forever in Python.  There must be a way to translate this calculation into a broadcast...</p>

<pre><code>def euclidean_square(a,b):
    squares = np.zeros((a.shape[0],b.shape[0]))
    for i in range(squares.shape[0]):
        for j in range(squares.shape[1]):
            diff = a[i,:] - b[j,:]
            sqr = diff**2.0
            squares[i,j] = np.sum(sqr)
    return squares
</code></pre>