title: Convert/Reshape 3D Matrix to a 2D Matrix
body: <p>I have a 3D matrix <code>X</code> which contains vectors as rows into the 3rd dimension. I would like to extract each such vector <code>X(:, x, y)</code> and save it as a 2D matrix such that <code>X(:, 0, 0)</code> is the first row of the 2D matrix, <code>X(:, 0, 1)</code> the second, and so on. The following crude graphic might help illustrate this:</p>
  
  <p><img src="https://i.stack.imgur.com/lsMbe.jpg" alt="Crude Sketch"></p>
  
  <p>I know that I can create my new 2D matrix and then iterate over the original <code>X</code> to add the vectors, but does somebody have some input on how to do this quick and efficiently?</p>
  
  <hr>
  
  <p>Example: Given</p>
  
  <pre><code>&gt;&gt;&gt; a = np.arange(9*3).reshape(3,3,3)
  &gt;&gt;&gt; a
  array([[[ 0,  1,  2],
          [ 3,  4,  5],
          [ 6,  7,  8]],
  
         [[ 9, 10, 11],
          [12, 13, 14],
          [15, 16, 17]],
  
         [[18, 19, 20],
          [21, 22, 23],
          [24, 25, 26]]])
  </code></pre>
  
  <p>I would like to get the following as rows, though the order of the rows does not matter:</p>
  
  <pre><code>array([[ 0,  9, 18],
         [ 1, 10, 19]],
         ...)
  </code></pre>