-
Notifications
You must be signed in to change notification settings - Fork 13
/
utils.py
44 lines (32 loc) · 927 Bytes
/
utils.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
# Author: Axel Mukwena
# ECG Biometric Authentication using Siamese and CNN
# import the necessary packages
import pickle
import random
import numpy as np
def load_data(where):
pickleIn = open(where, 'rb')
ps, yy, xx = pickle.load(pickleIn)
yy = np.array(yy)
xx = np.array(xx)
# Normalize data
print('Before Normalizing: Min:', xx.min(), 'Max:', xx.max(), "\n")
xx = (xx - xx.min()) / (xx.max() - xx.min())
print('After Normalizing: Min:', xx.min(), 'Max:', xx.max(), "\n")
return yy, xx, ps
# Shuffle data
def shuffle(yy, xx):
length = len(yy)
data = []
for i in range(length):
data.append([yy[i], xx[i]])
num = random.randint(0, length)
random.seed(num)
random.shuffle(data)
yy, xx = [], []
for k in range(length):
yy.append(data[k][0])
xx.append(data[k][1])
xx = np.array(xx)
yy = np.array(yy)
return yy, xx