-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_input.py
39 lines (27 loc) · 1.22 KB
/
user_input.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
#This program is used for giving custom user input to the NN and see the output.
from get_equivalent_letter import get_letter
# import mnist_loader
# training_data, validation_data, test_data = mnist_loader.load_data_wrapper()
import network2
import numpy as np
from nn_two_stage.second_nn import get_let_from_2nd_nn_ijltIL1
from nn_two_stage.second_nn import get_let_from_2nd_nn_ceg
def get_string_from_nn(all_letters):
net = network2.Network([1024, 30, 66], cost=network2.CrossEntropyCost)
biases_saved = np.load('biases.npy')
weights_saved = np.load('weights.npy')
#all_letters = np.load('all_letters.npy')
#all_letters = all_letters.tolist()
word_string = ""
i = 0
for x in all_letters:
output = np.argmax(net.feedforward(x, biases_saved = biases_saved, weights_saved = weights_saved))
#second stage classification below
if (output in (18, 19, 21, 29, 44, 47, 1)):
output = get_let_from_2nd_nn_ijltIL1(x)
elif (output in (12, 14, 42)):
output = get_let_from_2nd_nn_ceg(x)
word_string = word_string + get_letter(output)
i = i + 1
return word_string
#print np.argmax(net.feedforward(test_data[502][0], biases_saved = biases_saved, weights_saved = weights_saved))