-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
27 lines (22 loc) · 692 Bytes
/
run.py
File metadata and controls
27 lines (22 loc) · 692 Bytes
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
import tensorflow as tf
import numpy as np
from train import get_alphabet, text_to_vector
from autocorrect import Speller
spell = Speller()
def gen_text(model, inp, len):
alphabet = get_alphabet()
res = inp
for i in range(len):
vec = text_to_vector(inp)
vec = np.expand_dims(vec, axis=0)
index = np.argmax(model.predict(vec))
letter = alphabet[index]
res += letter
inp += letter
inp = inp[1:]
return spell(res)
model = tf.keras.models.load_model("save")
while True:
print ("============================")
print (gen_text(model, input("Enter seed phrase: "), 500))
print ("============================")