parameters: (filename)
docstring: Extract the images into a 4D uint8 numpy array [index, y, x, depth].
docstring_summary: Extract the images into a 4D uint8 numpy array [index, y, x, depth].
docstring_tokens: Extract the images into a 4D uint8 numpy array [ index y x depth ] .
function: def extract_images(filename):
    """Extract the images into a 4D uint8 numpy array [index, y, x, depth]."""
    print('Extracting', filename)
    with gzip.open(filename) as bytestream:
      magic = _read32(bytestream)
      if magic != 2051:
        raise ValueError(
            'Invalid magic number %d in MNIST image file: %s' %
            (magic, filename))
      num_images = _read32(bytestream)
      rows = _read32(bytestream)
      cols = _read32(bytestream)
      buf = bytestream.read(rows * cols * num_images)
      data = numpy.frombuffer(buf, dtype=numpy.uint8)
      data = data.reshape(num_images, rows, cols, 1)
      return data
function_tokens: def extract_images ( filename ) : print ( 'Extracting' , filename ) with gzip . open ( filename ) as bytestream : magic = _read32 ( bytestream ) if magic != 2051 : raise ValueError ( 'Invalid magic number %d in MNIST image file: %s' % ( magic , filename ) ) num_images = _read32 ( bytestream ) rows = _read32 ( bytestream ) cols = _read32 ( bytestream ) buf = bytestream . read ( rows * cols * num_images ) data = numpy . frombuffer ( buf , dtype = numpy . uint8 ) data = data . reshape ( num_images , rows , cols , 1 ) return data