-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·83 lines (72 loc) · 1.71 KB
/
test.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
import numpy as np
fileName = 'Data/facedata/facedatatrainlabels.txt'
f = open(fileName)
lines = f.readlines()
f.close()
# convert list of each line into integer list
integers = list(map(int, lines))
# initialize 10x1 numpy vector to represent labels
labels = [np.zeros((1, 1)) for i in range(len(lines))]
# make element at index of label to 1
for i, vector in zip(integers, labels):
vector[0][0] = i
print(labels)
# fileName = 'Data/digitdata/trainingimages.txt'
# f = open(fileName)
# lines = f.readlines()
# f.close()
#
# del lines[28*20]
# images = []
#
# i=0
# k=0
# image = np.zeros((28,28))
# while k < len(lines):
# if (i==28):
# i=0
# images.append(image)
# image = np.zeros((28,28))
# line = lines[k]
# for c,j in zip(line,range(0,28)):
# if c == '\n':
# continue
# elif c == '#':
# image[i][j] = 1
# elif c == '+':
# image[i][j] = .5
# k+=1
# i+=1
#
#
# print(images)
# features = [np.zeros(( img.size//4, 1) )for img in images]
# for image, ft in zip(images, features):
# x = np.nditer(ft, op_flags=['writeonly'])
# for i in range(0, 28, 2):
# for j in range(0, 28, 2):
# submatrix = image[i:i + 2, j:j + 2]
# x[0] = np.mean(submatrix)
# x.iternext()
# if (x.finished): break
# if (x.finished): break
#
#
# fileName = 'Data/digitdata/traininglabels.txt'
# f = open(fileName)
# lines = f.readlines()
# f.close()
#
# integers = list(map(int, lines))
# print(len(lines))
#
# labels = [np.zeros((10, 1)) for i in range(len(lines))]
#
# for i,vector in zip(integers, labels):
# vector[i][0] = 1
#
#
# print(features)
# print(images)
#
# # print(labels)