title: Apply max/average pooling after sparse coding with scikit learn for classification
body: <p>I messing around with sparse coding from <code>scikit-learn</code> and I want to try to classify images. I have images of size <code>128 x 128</code>. From this I extract random <code>7x7</code> patches to feed to kmeans which has 100 centroids. This means I have a dictionary of 100 atoms.
  So given an image to classify I first extract patches from this image with <code>extract_patches_2d</code>, which if I am not mistaken is also called <a href="http://ufldl.stanford.edu/wiki/index.php/Feature_extraction_using_convolution" rel="nofollow">convolutional sampling</a>. This means that I have (128-7+1)^2 patches for an image. I can encode every patch by the use of my dictionary and orthogonal matching persuit, leaving my with <code>(128-7+1)^2*(128-7+1)^2 * 100</code> (sparse) features. </p>
  
  <p>What would be the next step in order to transform this <code>(14884,100)</code> matrix to  a feature vector. From what I am reading this is done with average or max pooling, but I can't quite figure out how this works given this matrix.</p>