-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataLoad.py
More file actions
41 lines (34 loc) · 1.04 KB
/
dataLoad.py
File metadata and controls
41 lines (34 loc) · 1.04 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
import numpy as np
import os
import pickle
files = os.listdir("data")
x = []
x_load = []
y = []
y_load = []
def load_data():
count = 0
for file in files:
file = "data\\" + file
x = np.load(file)
x = x.astype('float32') / 255.
x = x[0:10000, :]
x_load.append(x)
print ( str(x.shape))
y = [count for _ in range(10000)]
count += 1
y = np.array(y).astype('float32')
y = y.reshape(y.shape[0], 1)
y_load.append(y)
print (str(y.shape))
return x_load, y_load
features, labels = load_data()
features = np.array(features).astype('float32')
labels = np.array(labels).astype('float32')
features=features.reshape(features.shape[0]*features.shape[1],features.shape[2])
labels=labels.reshape(labels.shape[0]*labels.shape[1],labels.shape[2])
print ("features:" + str(features.shape) + "labels" + str(labels.shape))
with open("features", "wb") as f:
pickle.dump(features, f, protocol=4)
with open("labels", "wb") as f:
pickle.dump(labels, f, protocol=4)