-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
74 lines (63 loc) · 1.76 KB
/
examples.py
File metadata and controls
74 lines (63 loc) · 1.76 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
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
from vmlp_multiclass import vmlp as multiclass_neural_network
from embedded_layer import EmbeddedLayer
import numpy
data = numpy.matrix([[0,0],[0,1],[1,0],[1,1]]) # input data
labels = numpy.matrix([[0,0,1],[1,0,0],[1,0,0],[0,0,1]]) # labels
user_model = multiclass_neural_network(data, labels, [2], 0.1, 2000)
# user_model.train()
# multiclass_neural_network.rawLabels()
# user_model.predictedLabels()
sparse_data = numpy.matrix([
[0, 0, 0, 0, 12, 108],
[0, 0, 0, 1, 12, 108],
[0, 0, 1, 0, 12, 108],
[0, 0, 1, 1, 12, 108],
[0, 1, 0, 0, 12, 108],
[0, 1, 0, 1, 12, 108],
[0, 1, 1, 0, 12, 108],
[0, 1, 1, 1, 12, 108],
[1, 0, 0, 0, 12, 108],
[1, 0, 0, 1, 12, 108],
[1, 0, 1, 0, 12, 108],
[1, 0, 1, 1, 12, 108],
[1, 1, 0, 0, 12, 108],
[1, 1, 0, 1, 12, 108],
[1, 1, 1, 0, 12, 108],
[1, 1, 1, 1, 12, 108],
])
sparse_labels = numpy.matrix([
[0, 0, 1],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[0, 0, 1],
])
embedded_model = multiclass_neural_network(sparse_data, sparse_labels, [2], 0.1, 2000)
embedded_layer = EmbeddedLayer(4, 2, 2, 3)
embedded_model.embedLayer(embedded_layer)
embedded_model.train()
embedded_model.predictedLabels()
def hamm(length):
hammed_dist = 2 ** length
rays = numpy.zeros([hammed_dist, length])
for i in range(0, hammed_dist):
bin_vector = list(bin(i)[2:])
if len(bin_vector) < length:
vector = [0] * (length - len(bin_vector))
rays[i] = vector + bin_vector
else:
rays[i] = bin_vector
for i in range(0,len(rays)):
print(rays[i])
# hamm(4)