This commit is contained in:
Nick
2019-10-30 07:25:11 -06:00
parent 666d8a07c8
commit 7f5c58cd0f
3 changed files with 12 additions and 5 deletions
+2 -2
View File
@@ -158,7 +158,7 @@ class CTRLGenerator():
if prompt[-1] != " ":
prompt = prompt + " "
#prompt = second_to_first_person(prompt)
prompt = second_to_first_person(prompt)
prompt = self.control_code + prompt
# print("\n\nAFTER PROMPT_REPLACE")
@@ -172,7 +172,7 @@ class CTRLGenerator():
first_letter_capitalized = result[0].isupper()
result = result.replace("#", "")
result = result.replace("*", "")
#result = first_to_second_person(result)
result = first_to_second_person(result)
result = remove_profanity(result)
if not first_letter_capitalized:
@@ -11,6 +11,7 @@ import argparse
import fastBPE
import platform
import json
from story.utils import *
def make_samples_helper(context, story_block, action_results, path, tree_id):
@@ -45,7 +46,13 @@ def build_tokenized_samples(bpe, tree):
sample[2] = sample[2][0].lower() + sample[2][1:]
sample[2] = "You " + sample[2]
string_samples.append(" ".join(sample))
new_sample = []
for item in sample:
new_sample.append(second_to_first_person(item))
string_samples.append(" ".join(new_sample))
tokenized_samples = [bpe.apply([sample.encode('ascii', errors='ignore') if not use_py3 else sample])[0] for sample in
string_samples] # will NOT work for non-English texts
@@ -65,7 +72,7 @@ use_py3 = platform.python_version()[0] == '3'
paths_to_train_files = ["apoc_seed1.json","apoc_seed2.json","apoc_seed3.json","apoc_seed4.json"]
seq_length = 256
domain = ["Writing", "Text@@", ":"]
domain = ["Apocalypse"]
# Build sequences from JSON
+1 -1
View File
@@ -142,7 +142,7 @@ def loss(labels, logits):
# the optimizer is not used since this code only supports inference
# however, to compile the model, we still define it
optimizer = tf.contrib.estimator.clip_gradients_by_norm(
tf.train.AdagradOptimizer(learning_rate=1e-4), 0.25)
tf.train.AdagradOptimizer(learning_rate=3e-3), 0.25)
# compile the model with the optimizer and loss
model.compile(optimizer=optimizer, loss=loss)