title: Numpy: find the euclidean distance between two 3-D arrays
body: <p>Given, two 3-D arrays of dimensions (2,2,2):</p>
  
  <pre><code>A = [[[ 0,  0],
      [92, 92]],
  
     [[ 0, 92],
      [ 0, 92]]]
  
  B = [[[ 0,  0],
      [92,  0]],
  
     [[ 0, 92],
      [92, 92]]]
  </code></pre>
  
  <p>How do you find the Euclidean distance for each vector in A and B efficiently?</p>
  
  <p>I have tried for-loops but these are slow, and I'm working with 3-D arrays in the order of (>>2, >>2, 2). </p>
  
  <p>Ultimately I want a matrix of the form:</p>
  
  <pre><code>C = [[d1, d2],
       [d3, d4]]
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I've tried the following loop, but the biggest issue with it is that loses the dimensions I want to keep. But the distances are correct.</p>
  
  <pre><code>[numpy.sqrt((A[row, col][0] - B[row, col][0])**2 + (B[row, col][1] -A[row, col][1])**2) for row in range(2) for col in range(2)]
  </code></pre>