title: Numpy N-Dimensional Array Unfolding
body: <p>I am basically trying to achieve <a href="https://stackoverflow.com/questions/32656712/numpy-convert-n-dimensional-array-into-two-dimensional-array">this</a>, but need the unfolding to be done in a different fashion. i want all samples of the <code>N-1th</code> dimension to be concatenated. For example, if my unfolding were to be applied to an RGB image of (100,100,3) the new array would basically become a (100,300) where the 3 colour channel images are now side by side in the new array. </p>
  
  <p>All my attempts to use a neat built in numpy function like <code>flatten</code> and <code>concatenate</code> yielded no results. (<code>flatten</code>, because the end goal is to apply this unfolding until it is a 1D array)</p>
  
  <p>Can't even think of a slicing way of doing it in a loop since the starting number of dimensions isn't constant (<code>array = array[:,...,:,0]+...+array[:,...,:,0]</code>)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I just came up with this way of achieving what I want, but would still welcome better, more pure, <code>numpy</code> solutions.</p>
  
  <pre><code>shape = numpy.random.randint(100, size=numpy.random.randint(100))
  array = numpy.random.uniform(size=shape)
  
  array = array.T
  for i in range(0, len(shape)-1, -1):
      array = numpy.concatenate(array)
  </code></pre>