(filename, sub_name, is_training,
                            batch_size, data_list)
return reader
reader creator
reader creator
reader creator
def reader_creator_filepath(filename, sub_name, is_training,
                            batch_size, data_list):
    """
        reader creator
    """
    dataset = []
    for name in data_list:
        print("Reading file " + name)
        file_path = os.path.join(filename, name)
        batch_data = pickle.load(open(file_path))
        dataset.append(batch_data)
    datasets = np.concatenate(dataset)
    if is_training:
        np.random.shuffle(dataset)

    def read_batch(datasets, is_training):
        """
            read batch
        """
        for sample, label in datasets:
            im = augmentation(sample, is_training)
            yield im, [int(label)]

    def reader():
        """
            get reader
        """
        batch_data = []
        batch_label = []
        for data, label in read_batch(datasets, is_training):
            batch_data.append(data)
            batch_label.append(label)
            if len(batch_data) == batch_size:
                batch_data = np.array(batch_data, dtype='float32')
                batch_label = np.array(batch_label, dtype='int64')
                batch_out = [[batch_data, batch_label]]
                yield batch_out
                batch_data = []
                batch_label = []
        if len(batch_data) != 0:
            batch_data = np.array(batch_data, dtype='float32')
            batch_label = np.array(batch_label, dtype='int64')
            batch_out = [[batch_data, batch_label]]
            yield batch_out
            batch_data = []
            batch_label = []
    return reader
def reader_creator_filepath ( filename , sub_name , is_training , batch_size , data_list ) : dataset = [ ] for name in data_list : print ( "Reading file " + name ) file_path = os . path . join ( filename , name ) batch_data = pickle . load ( open ( file_path ) ) dataset . append ( batch_data ) datasets = np . concatenate ( dataset ) if is_training : np . random . shuffle ( dataset ) def read_batch ( datasets , is_training ) : """
            read batch
        """ for sample , label in datasets : im = augmentation ( sample , is_training ) yield im , [ int ( label ) ] def reader ( ) : """
            get reader
        """ batch_data = [ ] batch_label = [ ] for data , label in read_batch ( datasets , is_training ) : batch_data . append ( data ) batch_label . append ( label ) if len ( batch_data ) == batch_size : batch_data = np . array ( batch_data , dtype = 'float32' ) batch_label = np . array ( batch_label , dtype = 'int64' ) batch_out = [ [ batch_data , batch_label ] ] yield batch_out batch_data = [ ] batch_label = [ ] if len ( batch_data ) != 0 : batch_data = np . array ( batch_data , dtype = 'float32' ) batch_label = np . array ( batch_label , dtype = 'int64' ) batch_out = [ [ batch_data , batch_label ] ] yield batch_out batch_data = [ ] batch_label = [ ] return reader