标签:参考 ORC rand div ima 获取数据 tps article and
方法一:使用np.random.shuffle
state = np.random.get_state()
np.random.shuffle(train)
np.random.set_state(state)
np.random.shuffle(label)
或者这么使用:
train_row = range(len(train_label)) random.shuffle(train_row) train_image = train_image[train_row] train_label = train_label[train_row]
方法二:使用np.random.permutation()
shuffle_ix = np.random.permutation(np.arange(len(train_data))) train_data = train_data[shuffle_ix] train_label = train_label[shuffle_ix]
方法三:使用pytorch中的Dataset,还可以设置batchsize的大小
dataset = torch.utils.data.TensorDataset(data, target) # 设置数据集 train_iter = torch.utils.data.DataLoader(dataset, batch_size, shuffle=True) # 设置获取数据方式
参考:
https://blog.csdn.net/sinat_38682860/article/details/108813209
标签:参考 ORC rand div ima 获取数据 tps article and
原文地址:https://www.cnblogs.com/xiximayou/p/13763027.html