def read_mnist_labels(fn):
 with open_if_filename(fn, 'rb') as f:
  (magic, number) = struct.unpack('>ii', f.read(8))
  if (magic != MNIST_LABEL_MAGIC):
   raise ValueError(('wrong magic number reading MNIST label file: ' + fn))
  array = numpy.fromfile(f, dtype='uint8')
 return array

def read_mnist_labels ( fn ) : with open_if_filename ( fn , 'rb' ) as f : ( magic , number ) = struct . unpack ( '>ii' , f . read ( 8 ) ) if ( magic != MNIST_LABEL_MAGIC ) : raise ValueError ( ( 'wrong magic number reading MNIST label file: ' + fn ) ) array = numpy . fromfile ( f , dtype = 'uint8' ) return array
read mnist labels from the original ubyte file format .