-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (30 loc) · 1.15 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
"""
9/18/17
kasim
"""
# TEST "this outstanding performance is achieved"
# used one hot encoding [i:e "this" = 1,0,0,0,0]
# used context size of 1 [i:e "outstanding has "this" and "performance" in its context]
import numpy as np
import Network
def get_distance_vector(matrix, i):
distance_vector = np.zeros(5)
for j in range(matrix.shape[0]):
distance = 0
for k in range(matrix.shape[1]):
distance+=(matrix[i][k]-matrix[j][k])**2
distance_vector[j] = distance
return distance_vector
n = Network.Network(5, 8)
data = np.array([(1, 0, 0, 0, 0, 0, 1, 0, 0, 0), (0, 1, 0, 0, 0, 1, 0, 0, 0, 0), (0, 1, 0, 0, 0, 0, 0, 1, 0, 0),
(0, 0, 1, 0, 0, 0, 1, 0, 0, 0), \
(0, 0, 1, 0, 0, 0, 0, 0, 1, 0), (0, 0, 0, 1, 0, 0, 0, 1, 0, 0), (0, 0, 0, 1, 0, 0, 0, 0, 0, 1),
(0, 0, 0, 0, 1, 0, 0, 0, 1, 0)])
features = n.train(500, 0.1, 8, data)
# distance matrix
print get_distance_vector(features, 0)
print get_distance_vector(features, 1)
print get_distance_vector(features, 2)
print get_distance_vector(features, 3)
print get_distance_vector(features, 4), "\n"