def extract_mnist_labels(filename, num_images):
 if (not tf.gfile.Exists((filename + '.npy'))):
  with gzip.open(filename) as bytestream:
   bytestream.read(8)
   buf = bytestream.read((1 * num_images))
   labels = np.frombuffer(buf, dtype=np.uint8).astype(np.int32)
   np.save(filename, labels)
  return labels
 else:
  with tf.gfile.Open((filename + '.npy'), mode='r') as file_obj:
   return np.load(file_obj)

def extract_mnist_labels ( filename , num_images ) : if ( not tf . gfile . Exists ( ( filename + '.npy' ) ) ) : with gzip . open ( filename ) as bytestream : bytestream . read ( 8 ) buf = bytestream . read ( ( 1 * num_images ) ) labels = np . frombuffer ( buf , dtype = np . uint8 ) . astype ( np . int32 ) np . save ( filename , labels ) return labels else : with tf . gfile . Open ( ( filename + '.npy' ) , mode = 'r' ) as file_obj : return np . load ( file_obj )
extract the labels into a vector of int64 label ids .