-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_loader.py
49 lines (36 loc) · 1.17 KB
/
data_loader.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
def train_set_loader():
f = open('data/Train_Arabic_Digit.txt', 'r')
plain_data = [line.split() for line in f]
train_set = []
length = []
sample = []
for i in range(len(plain_data) - 1):
if not plain_data[i + 1]:
train_set.append(sample)
length.append(len(sample))
sample = []
else:
sample.append([float(j) for j in plain_data[i + 1]])
train_set.append(sample)
length.append(len(sample))
return train_set, length
def test_set_loader():
f = open('data/Test_Arabic_Digit.txt', 'r')
plain_data = [line.split() for line in f]
test_set = []
length = []
sample = []
for i in range(len(plain_data) - 1):
if not plain_data[i + 1]:
test_set.append(sample)
length.append(len(sample))
sample = []
else:
sample.append([float(j) for j in plain_data[i + 1]])
test_set.append(sample)
length.append(len(sample))
return test_set, length
def dataset_loader():
train_set, train_len = train_set_loader()
test_set, testn_len = test_set_loader()
return train_set, train_len, test_set, testn_len