(self, file_name)
return np.array(images)
file_name:the byte file's direction
file_name:the byte file's direction
file_name : the byte file s direction
def read_images(self, file_name):
        """
           file_name:the byte file's direction
        """
        img_file = open(file_name, 'rb')
        print(img_file)
        # get the basic information about the images
        img_file.seek(0)
        magic_number = img_file.read(4)
        magic_number = struct.unpack('>i', magic_number)
        print('Magic Number: ' + str(magic_number[0]))

        data_type = img_file.read(4)
        data_type = struct.unpack('>i', data_type)
        print('Number of Images: ' + str(data_type[0]))

        dim = img_file.read(8)
        dimr = struct.unpack('>i', dim[0:4])
        dimr = dimr[0]
        print('Number of Rows: ' + str(dimr))
        dimc = struct.unpack('>i', dim[4:])
        dimc = dimc[0]
        print('Number of Columns:' + str(dimc))


        images=[]
        for idx in range(data_type[0]):
            image = np.ndarray(shape=(dimr, dimc))
            img_file.seek(16 + dimc * dimr * idx)

            for row in range(dimr):
                for col in range(dimc):
                    tmp_d = img_file.read(1)
                    tmp_d = struct.unpack('>B', tmp_d)
                    image[row, col] = tmp_d[0]
            images.append(image)
        return np.array(images)
def read_images ( self , file_name ) : img_file = open ( file_name , 'rb' ) print ( img_file ) # get the basic information about the images img_file . seek ( 0 ) magic_number = img_file . read ( 4 ) magic_number = struct . unpack ( '>i' , magic_number ) print ( 'Magic Number: ' + str ( magic_number [ 0 ] ) ) data_type = img_file . read ( 4 ) data_type = struct . unpack ( '>i' , data_type ) print ( 'Number of Images: ' + str ( data_type [ 0 ] ) ) dim = img_file . read ( 8 ) dimr = struct . unpack ( '>i' , dim [ 0 : 4 ] ) dimr = dimr [ 0 ] print ( 'Number of Rows: ' + str ( dimr ) ) dimc = struct . unpack ( '>i' , dim [ 4 : ] ) dimc = dimc [ 0 ] print ( 'Number of Columns:' + str ( dimc ) ) images = [ ] for idx in range ( data_type [ 0 ] ) : image = np . ndarray ( shape = ( dimr , dimc ) ) img_file . seek ( 16 + dimc * dimr * idx ) for row in range ( dimr ) : for col in range ( dimc ) : tmp_d = img_file . read ( 1 ) tmp_d = struct . unpack ( '>B' , tmp_d ) image [ row , col ] = tmp_d [ 0 ] images . append ( image ) return np . array ( images )