#NEWLINE# def read_mnist_labels( filename ) : #NEWLINE# #INDENT# 'Read MNIST labels from the original ubyte file format.\n\n    Parameters\n    ----------\n    filename : str\n        Filename/path from which to read labels.\n\n    Returns\n    -------\n    labels : :class:`~numpy.ndarray`, shape (nlabels, 1)\n        A one-dimensional unsigned byte array containing the\n        labels as integers.\n\n    ' #NEWLINE# with gzip . open ( filename , 'rb' ) as f : #NEWLINE# #INDENT# ( magic , _ ) = struct . unpack ( '>ii' , f . read ( 8 ) ) #NEWLINE# if ( magic != MNIST_LABEL_MAGIC ) : #NEWLINE# #INDENT# raise ValueError ( 'Wrong magic number reading MNIST label file' ) #NEWLINE# #UNINDENT# array = numpy . frombuffer ( f . read ( ) , dtype = 'uint8' ) #NEWLINE# #UNINDENT# array = array . reshape ( filename . size , 1 ) #NEWLINE# return array