1.通过数组来shuffle
image_list=[] # list of images
label_list=[] # list of labels
temp = np.array([image_list, label_list])
temp = temp.transpose()
np.random.shuffle(temp)
images = temp[:, 0] # array of images (N,)
labels = temp[:, 1]
2.通过索引 Index 来 shuffle
image_list=[] # list of images
label_list=[] # list of labels
##如果image_list存的是读取的特征数据,而不是图片路径,不要注释后面两句(list无法索引内部list)
#[list indices must be integers or slices, not list]
#image_list = np.array(image_list)
#label_list = np.array(label_list)
index = [i for i in range(len(image_list))]
np.random.shuffle(index)
images = image_list[index]
labels = label_list[index]