(f, one_hot=False, num_classes=10)
Extract the labels into a 1D uint8 np array [index].

  Args:
    f: A file object that can be passed into a gzip reader.
    one_hot: Does one hot encoding for the result.
    num_classes: Number of classes for the one hot encoding.

  Returns:
    labels: a 1D uint8 np array.

  Raises:
    ValueError: If the bystream doesn't start with 2049.
Extract the labels into a 1D uint8 np array [index].
Extract the labels into a 1D uint8 np array [ index ] .
def extract_labels(f, one_hot=False, num_classes=10):
  """Extract the labels into a 1D uint8 np array [index].

  Args:
    f: A file object that can be passed into a gzip reader.
    one_hot: Does one hot encoding for the result.
    num_classes: Number of classes for the one hot encoding.

  Returns:
    labels: a 1D uint8 np array.

  Raises:
    ValueError: If the bystream doesn't start with 2049.
  """
  tf.logging.info('Extracting', f.name)
  with gzip.GzipFile(fileobj=f) as bytestream:
    magic = _read32(bytestream)
    if magic != 2049:
      raise ValueError(
          'Invalid magic number %d in MNIST label file: %s' % (magic, f.name))
    num_items = _read32(bytestream)
    buf = bytestream.read(num_items)
    labels = np.frombuffer(buf, dtype=np.uint8)
    if one_hot:
      return dense_to_one_hot(labels, num_classes)
    return labels
def extract_labels ( f , one_hot = False , num_classes = 10 ) : tf . logging . info ( 'Extracting' , f . name ) with gzip . GzipFile ( fileobj = f ) as bytestream : magic = _read32 ( bytestream ) if magic != 2049 : raise ValueError ( 'Invalid magic number %d in MNIST label file: %s' % ( magic , f . name ) ) num_items = _read32 ( bytestream ) buf = bytestream . read ( num_items ) labels = np . frombuffer ( buf , dtype = np . uint8 ) if one_hot : return dense_to_one_hot ( labels , num_classes ) return labels