-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_hand.py
676 lines (532 loc) · 19.6 KB
/
data_hand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
import numpy as np
import tensorflow as tf
import tensorflow.keras as K
import tensorflow.keras as K
import os
import gzip
import cv2
#import keras as keras
import os
import scipy.io as scio
#from Utils2 import *
#from scipy.misc import imsave as ims
from tensorflow.keras import datasets
import tensorflow.keras as K
def GiveMNIST32_Tanh():
mnistName = "MNIST"
data_X, data_y = load_mnist_tanh(mnistName)
# data_X = np.expand_dims(data_X, axis=3)
data_X = np.concatenate((data_X, data_X, data_X), axis=-1)
size = (int(32), int(32))
myArr = []
for i in range(np.shape(data_X)[0]):
image = cv2.resize(data_X[i], size, interpolation=cv2.INTER_AREA)
myArr.append(image)
data_X = np.array(myArr)
x_train = data_X[0:60000]
x_test = data_X[60000:70000]
y_train = data_y[0:60000]
y_test = data_y[60000:70000]
mnist_train_x = x_train
mnist_train_label = y_train
mnist_test = x_test
mnist_label_test = y_test
return mnist_train_x, mnist_train_label, mnist_test, mnist_label_test
def GiveMNIST32():
mnistName = "MNIST"
data_X, data_y = load_mnist(mnistName)
# data_X = np.expand_dims(data_X, axis=3)
data_X = np.concatenate((data_X, data_X, data_X), axis=-1)
size = (int(32), int(32))
myArr = []
for i in range(np.shape(data_X)[0]):
image = cv2.resize(data_X[i], size, interpolation=cv2.INTER_AREA)
myArr.append(image)
data_X = np.array(myArr)
x_train = data_X[0:60000]
x_test = data_X[60000:70000]
y_train = data_y[0:60000]
y_test = data_y[60000:70000]
mnist_train_x = x_train
mnist_train_label = y_train
mnist_test = x_test
mnist_label_test = y_test
return mnist_train_x, mnist_train_label, mnist_test, mnist_label_test
def Give_InverseFashion32_Tanh():
mnistName = "Fashion"
data_X, data_y = load_mnist_tanh(mnistName)
data_X = np.reshape(data_X, (-1, 28, 28))
for i in range(np.shape(data_X)[0]):
for k1 in range(28):
for k2 in range(28):
data_X[i, k1, k2] = 1.0 - data_X[i, k1, k2]
data_X = np.reshape(data_X, (-1, 28, 28, 1))
data_X = np.concatenate((data_X, data_X, data_X), axis=-1)
size = (int(32), int(32))
myArr = []
for i in range(np.shape(data_X)[0]):
image = cv2.resize(data_X[i], size, interpolation=cv2.INTER_AREA)
myArr.append(image)
data_X = np.array(myArr)
x_train = data_X[0:60000]
x_test = data_X[60000:70000]
y_train = data_y[0:60000]
y_test = data_y[60000:70000]
mnist_train_x = x_train
mnist_train_label = y_train
mnist_test = x_test
mnist_label_test = y_test
return mnist_train_x,mnist_train_label,mnist_test,mnist_label_test
def Give_InverseFashion32():
mnistName = "Fashion"
data_X, data_y = load_mnist(mnistName)
data_X = np.reshape(data_X, (-1, 28, 28))
for i in range(np.shape(data_X)[0]):
for k1 in range(28):
for k2 in range(28):
data_X[i, k1, k2] = 1.0 - data_X[i, k1, k2]
data_X = np.reshape(data_X, (-1, 28, 28, 1))
data_X = np.concatenate((data_X, data_X, data_X), axis=-1)
size = (int(32), int(32))
myArr = []
for i in range(np.shape(data_X)[0]):
image = cv2.resize(data_X[i], size, interpolation=cv2.INTER_AREA)
myArr.append(image)
data_X = np.array(myArr)
x_train = data_X[0:60000]
x_test = data_X[60000:70000]
y_train = data_y[0:60000]
y_test = data_y[60000:70000]
mnist_train_x = x_train
mnist_train_label = y_train
mnist_test = x_test
mnist_label_test = y_test
return mnist_train_x,mnist_train_label,mnist_test,mnist_label_test
def ReturnSet_ByIndex(x,y,startIndex,endIndex):
xarr = []
yarr = []
difference = endIndex - 10
for i in range(np.shape(x)[0]):
if y[i] >= startIndex and y[i] <= endIndex:
xarr.append(x[i])
label = y[i] - difference
label = label-1
yarr.append(label)
xarr = np.array(xarr)
yarr = np.array(yarr)
return xarr,yarr
def ReturnSet_ByIndex2(x,y,startIndex,endIndex):
xarr = []
yarr = []
difference = endIndex - 20
for i in range(np.shape(x)[0]):
if y[i] >= startIndex and y[i] <= endIndex:
xarr.append(x[i])
label = y[i] - difference
label = label-1
yarr.append(label)
xarr = np.array(xarr)
yarr = np.array(yarr)
return xarr,yarr
def ReturnSet_ByIndex(x,y,startIndex,endIndex):
xarr = []
yarr = []
difference = endIndex - 10
for i in range(np.shape(x)[0]):
if y[i] >= startIndex and y[i] <= endIndex:
xarr.append(x[i])
label = y[i] - difference
label = label-1
yarr.append(label)
xarr = np.array(xarr)
yarr = np.array(yarr)
return xarr,yarr
def Split_CIFAR100_ReturnTesting():
(x_train, y_train), (x_test, y_test) = datasets.cifar100.load_data()
x_train = x_train/255
x_test = x_test/ 255
x1_,y1_ = ReturnSet_ByIndex(x_test,y_test,1,10)
x2_,y2_ = ReturnSet_ByIndex(x_test,y_test,11,20)
x3_,y3_ = ReturnSet_ByIndex(x_test,y_test,21,30)
x4_,y4_ = ReturnSet_ByIndex(x_test,y_test,31,40)
x5_,y5_ = ReturnSet_ByIndex(x_test,y_test,41,50)
'''
y1_ = to_categorical(y1_, num_classes=None)
y2_ = to_categorical(y2_, num_classes=None)
y3_ = to_categorical(y3_, num_classes=None)
y4_ = to_categorical(y4_, num_classes=None)
y5_ = to_categorical(y5_, num_classes=None)
'''
return x1_,y1_,x2_,y2_,x3_,y3_,x4_,y4_,x5_,y5_
def Split_CIFAR100_ReturnTesting_Special():
(x_train, y_train), (x_test, y_test) = datasets.cifar100.load_data()
x_train = x_train/255
x_test = x_test/ 255
#from keras.utils.np_utils import to_categorical
x1_,y1_ = ReturnSet_ByIndex(x_test,y_test,1,20)
x2_,y2_ = ReturnSet_ByIndex(x_test,y_test,21,40)
x3_,y3_ = ReturnSet_ByIndex(x_test,y_test,41,60)
x4_,y4_ = ReturnSet_ByIndex(x_test,y_test,61,80)
x5_,y5_ = ReturnSet_ByIndex(x_test,y_test,81,100)
y1_ = K.utils.to_categorical(y1_, num_classes=None)
y2_ = K.utils.to_categorical(y2_, num_classes=None)
y3_ = K.utils.to_categorical(y3_, num_classes=None)
y4_ = K.utils.to_categorical(y4_, num_classes=None)
y5_ = K.utils.to_categorical(y5_, num_classes=None)
return x1_,y1_,x2_,y2_,x3_,y3_,x4_,y4_,x5_,y5_
def Split_CIFAR100():
(x_train, y_train), (x_test, y_test) = datasets.cifar100.load_data()
x_train = x_train/255
x_test = x_test/ 255
x1,y1 = ReturnSet_ByIndex(x_train,y_train,1,10)
x2,y2 = ReturnSet_ByIndex(x_train,y_train,11,20)
x3,y3 = ReturnSet_ByIndex(x_train,y_train,21,30)
x4,y4 = ReturnSet_ByIndex(x_train,y_train,31,40)
x5,y5 = ReturnSet_ByIndex(x_train,y_train,41,50)
x1_,y1_ = ReturnSet_ByIndex(x_test,y_test,1,10)
x2_,y2_ = ReturnSet_ByIndex(x_test,y_test,11,20)
x3_,y3_ = ReturnSet_ByIndex(x_test,y_test,21,30)
x4_,y4_ = ReturnSet_ByIndex(x_test,y_test,31,40)
x5_,y5_ = ReturnSet_ByIndex(x_test,y_test,41,50)
x_ = np.concatenate((x1_,x2_,x3_,x4_,x5_),axis=0)
y_ = np.concatenate((y1_,y2_,y3_,y4_,y5_),axis=0)
return x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x_,y_
def Split_CIFAR100_2():
(x_train, y_train), (x_test, y_test) = datasets.cifar100.load_data()
x_train = x_train/255
x_test = x_test/ 255
x1,y1 = ReturnSet_ByIndex2(x_train,y_train,1,20)
x2,y2 = ReturnSet_ByIndex2(x_train,y_train,21,40)
x3,y3 = ReturnSet_ByIndex2(x_train,y_train,41,60)
x4,y4 = ReturnSet_ByIndex2(x_train,y_train,61,80)
x5,y5 = ReturnSet_ByIndex2(x_train,y_train,81,100)
x1_,y1_ = ReturnSet_ByIndex2(x_test,y_test,1,20)
x2_,y2_ = ReturnSet_ByIndex2(x_test,y_test,21,40)
x3_,y3_ = ReturnSet_ByIndex2(x_test,y_test,41,60)
x4_,y4_ = ReturnSet_ByIndex2(x_test,y_test,61,80)
x5_,y5_ = ReturnSet_ByIndex2(x_test,y_test,81,100)
x_ = np.concatenate((x1_,x2_,x3_,x4_,x5_),axis=0)
y_ = np.concatenate((y1_,y2_,y3_,y4_,y5_),axis=0)
return x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x_,y_
def Split_CIFAR100_3():
(x_train, y_train), (x_test, y_test) = datasets.cifar100.load_data()
x_train = x_train/255
x_test = x_test/ 255
x1,y1 = ReturnSet_ByIndex2(x_train,y_train,1,20)
x2,y2 = ReturnSet_ByIndex2(x_train,y_train,21,40)
x3,y3 = ReturnSet_ByIndex2(x_train,y_train,41,60)
x4,y4 = ReturnSet_ByIndex2(x_train,y_train,61,80)
x5,y5 = ReturnSet_ByIndex2(x_train,y_train,81,100)
x1_,y1_ = ReturnSet_ByIndex2(x_test,y_test,1,20)
x2_,y2_ = ReturnSet_ByIndex2(x_test,y_test,21,40)
x3_,y3_ = ReturnSet_ByIndex2(x_test,y_test,41,60)
x4_,y4_ = ReturnSet_ByIndex2(x_test,y_test,61,80)
x5_,y5_ = ReturnSet_ByIndex2(x_test,y_test,81,100)
x_ = np.concatenate((x1_,x2_,x3_,x4_,x5_),axis=0)
y_ = np.concatenate((y1_,y2_,y3_,y4_,y5_),axis=0)
return x1_,y1_,x2_,y2_,x3_,y3_,x4_,y4_,x5_,y5_
def Give_InverseDataset(name):
data_X, data_y = load_mnist(name)
data_X = np.reshape(data_X, (-1, 28, 28))
for i in range(np.shape(data_X)[0]):
for k1 in range(28):
for k2 in range(28):
data_X[i, k1, k2] = 1.0 - data_X[i, k1, k2]
data_X = np.reshape(data_X,(-1,28*28))
return data_X,data_y
def GiveLifelongTasks_AcrossDomain():
(train_images_nonbinary, y_train), (test_images_nonbinary, y_test) = tf.keras.datasets.mnist.load_data()
train_images_nonbinary = train_images_nonbinary.reshape(train_images_nonbinary.shape[0], 28 * 28)
test_images_nonbinary = test_images_nonbinary.reshape(test_images_nonbinary.shape[0], 28 * 28)
'''
y_train = tf.cast(y_train, tf.int64)
y_test = tf.cast(y_test, tf.int64)
'''
train_images = train_images_nonbinary / 255.
test_images = test_images_nonbinary / 255.
'''
# Binarization
train_images[train_images >= .5] = 1.
train_images[train_images < .5] = 0.
test_images[test_images >= .5] = 1.
test_images[test_images < .5] = 0.
'''
mnistTrain = train_images
mnistTest = test_images
mnistName = "Fashion"
data_X, data_y = load_mnist(mnistName)
data_X = np.reshape(data_X,(-1,28*28))
# data_X = np.expand_dims(data_X, axis=3)
x_train = data_X[0:60000]
x_test = data_X[60000:70000]
'''
x_train[x_train >= .5] = 1.
x_train[x_train < .5] = 0.
x_test[x_test >= .5] = 1.
x_test[x_test < .5] = 0.
'''
fashionTrain = x_train
fashionTest = x_test
imnistX = Give_InverseDataset("mnist")
ifashionX = Give_InverseDataset("Fashion")
'''
imnistX[imnistX >= .5] = 1.
imnistX[imnistX < .5] = 0.
ifashionX[ifashionX >= .5] = 1.
ifashionX[ifashionX < .5] = 0.
'''
imnistTrainX = imnistX[0:60000]
imnistTestX = imnistX[60000:70000]
ifashionTrainX = ifashionX[0:60000]
ifashionTestX = ifashionX[60000:70000]
return mnistTrain,mnistTest,fashionTrain,fashionTest,imnistTrainX,imnistTestX,ifashionTrainX,ifashionTestX
def Load_Caltech101(isBinarized):
dataFile = 'data/caltech101_silhouettes_28_split1.mat'
data = scio.loadmat(dataFile)
bc = 0
trainingSet = data["train_data"]
testingSet = data["test_data"]
return trainingSet,testingSet
def Load_OMNIST(isBinarized):
dataFile = 'data/omniglot.mat'
dataFile = 'data/chardata.mat'
data = scio.loadmat(dataFile)
myData = data["data"]
myData = myData.transpose(1, 0)
#if isBinarized == True:
# myData[myData >= .5] = 1.
# myData[myData < .5] = 0.
trainingSet = myData
testingSet = data["testdata"]
testingSet = testingSet.transpose(1, 0)
return trainingSet,testingSet
'''
from utils import *
dataFile = 'data/chardata.mat'
data = scio.loadmat(dataFile)
myData = data["testdata"]
myData = myData.transpose(1, 0)
batch = myData[0:64]
batch = np.reshape(batch,(-1,28,28,1))
print(batch[0])
batch = batch * 255.0
cv2.imwrite(os.path.join("results/", 'a1.png'), merge2(batch[:64], [8, 8]))
bb = 0
'''
def load_mnist_tanh(dataset_name):
data_dir = os.path.join("./data", dataset_name)
def extract_data(filename, num_data, head_size, data_size):
with gzip.open(filename) as bytestream:
bytestream.read(head_size)
buf = bytestream.read(data_size * num_data)
data = np.frombuffer(buf, dtype=np.uint8).astype(np.float)
return data
data = extract_data(data_dir + '/train-images-idx3-ubyte.gz', 60000, 16, 28 * 28)
trX = data.reshape((60000, 28, 28, 1))
data = extract_data(data_dir + '/train-labels-idx1-ubyte.gz', 60000, 8, 1)
trY = data.reshape((60000))
data = extract_data(data_dir + '/t10k-images-idx3-ubyte.gz', 10000, 16, 28 * 28)
teX = data.reshape((10000, 28, 28, 1))
data = extract_data(data_dir + '/t10k-labels-idx1-ubyte.gz', 10000, 8, 1)
teY = data.reshape((10000))
trY = np.asarray(trY)
teY = np.asarray(teY)
X = np.concatenate((trX, teX), axis=0)
y = np.concatenate((trY, teY), axis=0).astype(np.int)
seed = 547
np.random.seed(seed)
np.random.shuffle(X)
np.random.seed(seed)
np.random.shuffle(y)
y_vec = np.zeros((len(y), 10), dtype=np.float)
for i, label in enumerate(y):
y_vec[i, y[i]] = 1.0
X = X / 127.5 -1
return X, y_vec
def load_mnist(dataset_name):
data_dir = os.path.join("./data", dataset_name)
def extract_data(filename, num_data, head_size, data_size):
with gzip.open(filename) as bytestream:
bytestream.read(head_size)
buf = bytestream.read(data_size * num_data)
data = np.frombuffer(buf, dtype=np.uint8).astype(np.float)
return data
data = extract_data(data_dir + '/train-images-idx3-ubyte.gz', 60000, 16, 28 * 28)
trX = data.reshape((60000, 28, 28, 1))
data = extract_data(data_dir + '/train-labels-idx1-ubyte.gz', 60000, 8, 1)
trY = data.reshape((60000))
data = extract_data(data_dir + '/t10k-images-idx3-ubyte.gz', 10000, 16, 28 * 28)
teX = data.reshape((10000, 28, 28, 1))
data = extract_data(data_dir + '/t10k-labels-idx1-ubyte.gz', 10000, 8, 1)
teY = data.reshape((10000))
trY = np.asarray(trY)
teY = np.asarray(teY)
X = np.concatenate((trX, teX), axis=0)
y = np.concatenate((trY, teY), axis=0).astype(np.int)
seed = 547
np.random.seed(seed)
np.random.shuffle(X)
np.random.seed(seed)
np.random.shuffle(y)
y_vec = np.zeros((len(y), 10), dtype=np.float)
for i, label in enumerate(y):
y_vec[i, y[i]] = 1.0
return X / 255., y_vec
def Split_dataset_by10(x,y):
arr1 = []
arr2 = []
arr3 = []
arr4 = []
arr5 = []
arr6 = []
arr7 = []
arr8 = []
arr9 = []
arr10 = []
labelArr1 = []
labelArr2 = []
labelArr3 = []
labelArr4 = []
labelArr5 = []
labelArr6 = []
labelArr7 = []
labelArr8 = []
labelArr9 = []
labelArr10 = []
n = np.shape(x)[0]
for i in range(n):
data1 = x[i]
label1 = y[i]
if label1[0] == 1:
arr1.append(data1)
labelArr1.append(label1)
elif label1[1] == 1:
arr2.append(data1)
labelArr2.append(label1)
elif label1[2] == 1:
arr3.append(data1)
labelArr3.append(label1)
elif label1[3] == 1:
arr4.append(data1)
labelArr4.append(label1)
elif label1[4] == 1:
arr5.append(data1)
labelArr5.append(label1)
elif label1[5] == 1:
arr6.append(data1)
labelArr6.append(label1)
elif label1[6] == 1:
arr7.append(data1)
labelArr7.append(label1)
elif label1[7] == 1:
arr8.append(data1)
labelArr8.append(label1)
elif label1[8] == 1:
arr9.append(data1)
labelArr9.append(label1)
elif label1[9] == 1:
arr10.append(data1)
labelArr10.append(label1)
arr1 = np.array(arr1)
arr2 = np.array(arr2)
arr3 = np.array(arr3)
arr4 = np.array(arr4)
arr5 = np.array(arr5)
arr6 = np.array(arr6)
arr7 = np.array(arr7)
arr8 = np.array(arr8)
arr9 = np.array(arr9)
arr10 = np.array(arr10)
labelArr1 = np.array(labelArr1)
labelArr2 = np.array(labelArr2)
labelArr3 = np.array(labelArr3)
labelArr4 = np.array(labelArr4)
labelArr5 = np.array(labelArr5)
labelArr6 = np.array(labelArr6)
labelArr7 = np.array(labelArr7)
labelArr8 = np.array(labelArr8)
labelArr9 = np.array(labelArr9)
labelArr10 = np.array(labelArr10)
return arr1, labelArr1, arr2, labelArr2, arr3, labelArr3, arr4, labelArr4, arr5, labelArr5,arr6, labelArr6,arr7, labelArr7,arr8, labelArr8,arr9, labelArr9,arr10, labelArr10
def Split_dataset_by5(x,y):
arr1 = []
arr2 = []
arr3 = []
arr4 = []
arr5 = []
labelArr1 = []
labelArr2 = []
labelArr3 = []
labelArr4 = []
labelArr5 = []
n = np.shape(x)[0]
for i in range(n):
data1 = x[i]
label1 = y[i]
if label1[0] == 1 or label1[1] == 1:
arr1.append(data1)
labelArr1.append(label1)
if label1[2] == 1 or label1[3] == 1:
arr2.append(data1)
labelArr2.append(label1)
if label1[4] == 1 or label1[5] == 1:
arr3.append(data1)
labelArr3.append(label1)
if label1[6] == 1 or label1[7] == 1:
arr4.append(data1)
labelArr4.append(label1)
if label1[8] == 1 or label1[9] == 1:
arr5.append(data1)
labelArr5.append(label1)
arr1 = np.array(arr1)
arr2 = np.array(arr2)
arr3 = np.array(arr3)
arr4 = np.array(arr4)
arr5 = np.array(arr5)
labelArr1 = np.array(labelArr1)
labelArr2 = np.array(labelArr2)
labelArr3 = np.array(labelArr3)
labelArr4 = np.array(labelArr4)
labelArr5 = np.array(labelArr5)
return arr1,labelArr1,arr2,labelArr2,arr3,labelArr3,arr4,labelArr4,arr5,labelArr5
def Split_dataset_by5_Specal(x,y):
arr1 = []
arr2 = []
arr3 = []
arr4 = []
arr5 = []
labelArr1 = []
labelArr2 = []
labelArr3 = []
labelArr4 = []
labelArr5 = []
n = np.shape(x)[0]
for i in range(n):
data1 = x[i]
label1 = y[i]
if label1[0] == 1 or label1[1] == 1:
arr1.append(data1)
labelArr1.append(label1)
if label1[2] == 1 or label1[3] == 1:
arr2.append(data1)
labelArr2.append(label1)
if label1[4] == 1 or label1[5] == 1:
arr3.append(data1)
labelArr3.append(label1)
if label1[6] == 1 or label1[7] == 1:
arr4.append(data1)
labelArr4.append(label1)
if label1[8] == 1 or label1[9] == 1:
arr5.append(data1)
labelArr5.append(label1)
arr1 = np.array(arr1)
arr2 = np.array(arr2)
arr3 = np.array(arr3)
arr4 = np.array(arr4)
arr5 = np.array(arr5)
labelArr1 = np.array(labelArr1)
labelArr2 = np.array(labelArr2)
labelArr3 = np.array(labelArr3)
labelArr4 = np.array(labelArr4)
labelArr5 = np.array(labelArr5)
return arr1,labelArr1,arr2,labelArr2,arr3,labelArr3,arr4,labelArr4,arr5,labelArr5