载入数据
import numpy as np import random input1 = np.load('/root/whq/input/one_hot_1400/xf_p_n.npy') input2 = np.load('/root/whq/input/one_hot_1400/gf_p_n.npy') output_ = np.load('/root/whq/input/one_hot_1400/label_p_n_-1.npy') output_0 = np.load('/root/whq/input/one_hot_1400/label_p_n_0.npy')
shuffle
all = list(zip(input1, input2, output_, output_0)) # 4元元组列表 random.shuffle(all) input1, input2, output_, output_0 = zip(*all) # 按列拆开,每列->新元组
存为numpy格式
input1 = np.array(list(input1)) # 元组->list->numpy input2 = np.array(list(input2)) output_ = np.array(list(output_)) output_0 = np.array(list(output_0)) np.save('/root/whq/input/one_hot_1400_shuffle/xf_id.npy', input1) np.save('/root/whq/input/one_hot_1400_shuffle/gf_id.npy', input2) np.save('/root/whq/input/one_hot_1400_shuffle/label_p_n_-1.npy', output_) np.save('/root/whq/input/one_hot_1400_shuffle/label_p_n_0.npy', output_0)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)