数据划分处理代码

 1 train_x = []
 2 val_x = []
 3 test_x = []
 4 
 5 train_y = []
 6 val_y = []
 7 test_y = []
 8 
 9 samples = np.split(data, 100)
10 targets = np.split(labels, 100)
11 
12 for sample in samples:
13     train_x.extend(sample[0:12])
14     val_x.extend(sample[12:17])
15     test_x.extend(sample[17:24])
16 
17 for target in targets:
18     train_y.extend(target[0:12])
19     val_y.extend(target[12:17])
20     test_y.extend(target[17:24])
21 
22 print(len(train_x), len(val_y), len(test_x))
23 print(len(train_y), len(val_y), len(test_y))
24 print(train_x)
View Code

猜你喜欢

转载自www.cnblogs.com/Junlong/p/11367378.html