code: def _getDataBatch(self, inputData):
      
      if not hasattr(self, 'numImages'):
        self._initializeDimensions(inputData)
  
      batch = np.zeros((self.filterDim, self.batchSize))
  
      # choose correct patch size
      if self.imageHeight is None:
        patchSize = self.filterDim
      elif self.numChannels is None or self.numChannels == 0:
        patchSize = int(np.sqrt(self.filterDim))
      else:
        patchSize = int(np.sqrt(self.filterDim / self.numChannels))
  
      minIndex = patchSize / 2
  
      for i in xrange(self.batchSize):
        # choose random image
        imageIdx = np.random.choice(range(self.numImages))
  
        # pick random starting row
        rows = self.imageHeight - 2 * patchSize
        rowNumber = minIndex + np.random.choice(range(rows))
  
        if self.imageHeight is None:
          patch = inputData[rowNumber : rowNumber + patchSize, imageIdx]
        else:
          # pick random starting column
          cols = self.imageWidth - 2 * patchSize
          colNumber = minIndex + np.random.choice(range(cols))
  
          if self.numChannels is None:
            patch = inputData[rowNumber : rowNumber + patchSize,
                              colNumber : colNumber + patchSize,
                              imageIdx]
          else:
            patch = inputData[rowNumber : rowNumber + patchSize,
                              colNumber : colNumber + patchSize,
                              :, imageIdx]
        patch = np.reshape(patch, newshape=(self.filterDim, ))
        batch[:, i] = patch
  
      return batch
docs: Returns an array of dimensions (filterDim, batchSize), to be used as
      batch for training data.
  
      This implementation uses random sub-patches as training batch.
  
      Images are flattened to get a 2-dimensional batch.