def extract_labels(filename, num_images):
 print('Extracting', filename)
 with gzip.open(filename) as bytestream:
  bytestream.read(8)
  buf = bytestream.read((1 * num_images))
  labels = numpy.frombuffer(buf, dtype=numpy.uint8).astype(numpy.int64)
 return labels

def extract_labels ( filename , num_images ) : print ( 'Extracting' , filename ) with gzip . open ( filename ) as bytestream : bytestream . read ( 8 ) buf = bytestream . read ( ( 1 * num_images ) ) labels = numpy . frombuffer ( buf , dtype = numpy . uint8 ) . astype ( numpy . int64 ) return labels
extract the labels into a vector of int64 label ids .