def make_grid(image_batch):
  """
  Turns a batch of images into one big image.
  :param image_batch: ndarray, shape (batch_size, rows, cols, channels)
  :returns : a big image containing all `batch_size` images in a grid
  """
  m, ir, ic, ch = image_batch.shape

  pad = 3

  padded = np.zeros((m, ir + pad * 2, ic + pad * 2, ch))
  padded[:, pad:-pad, pad:-pad, :] = image_batch

  m, ir, ic, ch = padded.shape

  pr = int(np.sqrt(m))
  pc = int(np.ceil(float(m) / pr))
  extra_m = pr * pc
  assert extra_m > m

  padded = np.concatenate((padded, np.zeros((extra_m - m, ir, ic, ch))), axis=0)

  row_content = np.split(padded, pr)
  row_content = [np.split(content, pc) for content in row_content]
  rows = [np.concatenate(content, axis=2) for content in row_content]
  grid = np.concatenate(rows, axis=1)
  assert grid.shape[0] == 1, grid.shape
  grid = grid[0]

  return grid
def make_grid ( image_batch ) : m , ir , ic , ch = image_batch . shape pad = 3 padded = np . zeros ( ( m , ir + pad * 2 , ic + pad * 2 , ch ) ) padded [ : , pad : - pad , pad : - pad , : ] = image_batch m , ir , ic , ch = padded . shape pr = int ( np . sqrt ( m ) ) pc = int ( np . ceil ( float ( m ) / pr ) ) extra_m = pr * pc assert extra_m > m padded = np . concatenate ( ( padded , np . zeros ( ( extra_m - m , ir , ic , ch ) ) ) , axis = 0 ) row_content = np . split ( padded , pr ) row_content = [ np . split ( content , pc ) for content in row_content ] rows = [ np . concatenate ( content , axis = 2 ) for content in row_content ] grid = np . concatenate ( rows , axis = 1 ) assert grid . shape [ 0 ] == 1 , grid . shape grid = grid [ 0 ] return grid
Turns a batch of images into one big image.
  :param image_batch: ndarray, shape (batch_size, rows, cols, channels)
  :returns : a big image containing all `batch_size` images in a grid