-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_model.py
67 lines (50 loc) · 1.88 KB
/
load_model.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
import tensorflow as tf
import json
import sys
from train_model import build_column
from card_name_to_vector import card_name_to_vector
card_vector_size = 234
card_1 = tf.placeholder('float32', [None, card_vector_size])
card_2 = tf.placeholder('float32', [None, card_vector_size])
card_3 = tf.placeholder('float32', [None, card_vector_size])
output_1 = build_column(card_1)
output_2 = build_column(card_2)
output_3 = build_column(card_3)
output = output_1 + output_2 + output_3
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess, sys.argv[1])
while True:
try:
while True:
try:
card_1_name = input('Card 1: ').strip()
card_1_vector = card_name_to_vector(card_1_name)
break
except StopIteration:
print('Card Not Found')
while True:
try:
card_2_name = input('Card 2: ').strip()
card_2_vector = card_name_to_vector(card_2_name)
break
except StopIteration:
print('Card Not Found')
while True:
try:
card_3_name = input('Card 3: ').strip()
card_3_vector = card_name_to_vector(card_3_name)
break
except StopIteration:
print('Card Not Found')
output_ = list(sess.run(output, feed_dict={
card_1: [card_1_vector],
card_2: [card_2_vector],
card_3: [card_3_vector],
})[0])
choices = ['Skip', card_1_name, card_2_name, card_3_name]
print('The Neural Network chooses: {choice}'.format(
choice=choices[output_.index(max(output_))].title()
))
except KeyboardInterrupt:
break