-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation_data.py
More file actions
48 lines (40 loc) · 1.29 KB
/
Copy pathvalidation_data.py
File metadata and controls
48 lines (40 loc) · 1.29 KB
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
from collections import Counter
import os
import pandas as pd
import numpy as np
import tensorflow as tf
from imblearn.over_sampling import SMOTE
import time
from imblearn.over_sampling import RandomOverSampler
from imblearn.over_sampling import ADASYN
list11 = [] # data
list22 = [] # label_2
list1010 = [] # label_10
for serialized_example in tf.compat.v1.io.tf_record_iterator("normalized/validation_select_12.tfrecords"):
example = tf.train.Example()
example.ParseFromString(serialized_example)
feature = example.features.feature['features'].float_list.value
label_2 = example.features.feature['label_2'].float_list.value
label_10 = example.features.feature['label_10'].float_list.value
list11.append(feature)
list22.append(label_2)
list1010.append(label_10)
XX=np.array(list11)
b22=np.array(list22)
bb22=b22.reshape(b22.shape[0],)
b1010=np.array(list1010)
bb1010=b1010.reshape(b1010.shape[0],)
y22 = np.int32(bb22)
y1010 = np.int32(bb1010)
print(y22.shape)
print(y1010.shape)
print(XX.shape)
print(Counter(y22))
print(Counter(y1010))
yy22 = y22.reshape(y22.shape[0],1)
print(yy22.shape)
yy1010 = y1010.reshape(y1010.shape[0],1)
print(yy1010.shape)
np.save("alldata/data_12_val.npy",XX)
np.save("alldata/label_2_12_val.npy",yy22)
np.save("alldata/label_10_12_val.npy",yy1010)