added print wrapping

This commit is contained in:
Nick Walton
2019-11-18 12:49:24 -07:00
parent 305e898c56
commit 26bcad6ada
2 changed files with 12 additions and 3 deletions
+12 -1
View File
@@ -8,7 +8,18 @@ CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json"
def console_print(text, width=75):
print(textwrap.fill(text, width))
last_newline = 0
i = 0
while i < len(text):
if text[i] == "\n":
last_newline = 0
elif last_newline > width:
text = text[:i] + "\n" + text[i:]
else:
last_newline += 1
i += 1
def play_unconstrained():
-2
View File
@@ -11,8 +11,6 @@ from generator.gpt2.src import model, sample, encoder
import json
import numpy as np
tf.logging.set_verbosity(tf.logging.ERROR)
class GPT2Generator:
def __init__(self, generate_num=100, temperature=0.3, top_k=40, top_p=0.8):