def displayData(X, size=None, showit=False):
 x_length = int(np.sqrt(X.shape[1]))
 y_length = int(np.sqrt(X.shape[1]))
 if (size == None):
  size = np.sqrt(X.shape[0])
  size = [size, size]
 bigimg = np.zeros(((x_length * size[0]), (y_length * size[1])))
 for i in range(x_length):
  for j in range(y_length):
   im = X[:, (((i - 1) * y_length) + j)].reshape(32, 32).transpose()
   bigimg[(i * 32):((i + 1) * 32), (j * 32):((j + 1) * 32)] = im
 if showit:
  fig = plt.figure()
  plt.imshow(bigimg, cmap='gray')
 else:
  return bigimg

def displayData ( X , size = None , showit = False ) : x_length = int ( np . sqrt ( X . shape [ 1 ] ) ) y_length = int ( np . sqrt ( X . shape [ 1 ] ) ) if ( size == None ) : size = np . sqrt ( X . shape [ 0 ] ) size = [ size , size ] bigimg = np . zeros ( ( ( x_length * size [ 0 ] ) , ( y_length * size [ 1 ] ) ) ) for i in range ( x_length ) : for j in range ( y_length ) : im = X [ : , ( ( ( i - 1 ) * y_length ) + j ) ] . reshape ( 32 , 32 ) . transpose ( ) bigimg [ ( i * 32 ) : ( ( i + 1 ) * 32 ) , ( j * 32 ) : ( ( j + 1 ) * 32 ) ] = im if showit : fig = plt . figure ( ) plt . imshow ( bigimg , cmap = 'gray' ) else : return bigimg
x is a n*m matrix size show each images size .