def load_MNIST_images(filename):
 with open(filename, 'r') as f:
  magic = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
  num_images = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
  num_rows = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
  num_cols = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
  images = np.fromfile(f, dtype=np.ubyte)
  images = images.reshape((num_images, (num_rows * num_cols))).transpose()
  images = (images.astype(np.float64) / 255)
  f.close()
  return images

def load_MNIST_images ( filename ) : with open ( filename , 'r' ) as f : magic = np . fromfile ( f , dtype = np . dtype ( '>i4' ) , count = 1 ) num_images = np . fromfile ( f , dtype = np . dtype ( '>i4' ) , count = 1 ) num_rows = np . fromfile ( f , dtype = np . dtype ( '>i4' ) , count = 1 ) num_cols = np . fromfile ( f , dtype = np . dtype ( '>i4' ) , count = 1 ) images = np . fromfile ( f , dtype = np . ubyte ) images = images . reshape ( ( num_images , ( num_rows * num_cols ) ) ) . transpose ( ) images = ( images . astype ( np . float64 ) / 255 ) f . close ( ) return images
returns a 28x28x[number of mnist images] matrix containing the raw mnist images .