(input_dir, chunk_size)
return np.array(datasets)
get image datasets
        chunk_size is the number of each class
get image datasets
        chunk_size is the number of each class
get image datasets chunk_size is the number of each class
def get_datasets(input_dir, chunk_size):
    """
        get image datasets
        chunk_size is the number of each class
    """
    total_size = chunk_size * 10
    names = get_file_names(parse_args.input_dir)
    img_count = 0
    datasets = []
    class_map = {i: 0 for i in range(10)}
    for name in names:
        print("Reading file " + name)
        batch = pickle.load(open(input_dir + "/" + name, 'rb'))
        data = batch['data']
        labels = batch.get('labels', batch.get('fine_labels', None))
        assert labels is not None
        data_tuples = zip(data, labels)
        for data in data_tuples:
            if class_map[data[1]] < chunk_size:
                datasets.append(data)
                class_map[data[1]] += 1
                img_count += 1
                if img_count >= total_size:
                    random.shuffle(datasets)
                    for k, v in class_map.items():
                        print("label:{} count:{}".format(k, v))
                    return np.array(datasets)
    random.shuffle(datasets)
    return np.array(datasets)
def get_datasets ( input_dir , chunk_size ) : total_size = chunk_size * 10 names = get_file_names ( parse_args . input_dir ) img_count = 0 datasets = [ ] class_map = { i : 0 for i in range ( 10 ) } for name in names : print ( "Reading file " + name ) batch = pickle . load ( open ( input_dir + "/" + name , 'rb' ) ) data = batch [ 'data' ] labels = batch . get ( 'labels' , batch . get ( 'fine_labels' , None ) ) assert labels is not None data_tuples = zip ( data , labels ) for data in data_tuples : if class_map [ data [ 1 ] ] < chunk_size : datasets . append ( data ) class_map [ data [ 1 ] ] += 1 img_count += 1 if img_count >= total_size : random . shuffle ( datasets ) for k , v in class_map . items ( ) : print ( "label:{} count:{}" . format ( k , v ) ) return np . array ( datasets ) random . shuffle ( datasets ) return np . array ( datasets )