diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index f4cf0df..7af62c0 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -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: diff --git a/generator/ctrl/training_utils/make_forest_tf_records.py b/generator/ctrl/training_utils/make_forest_tf_records.py index 4685e1f..11217b8 100644 --- a/generator/ctrl/training_utils/make_forest_tf_records.py +++ b/generator/ctrl/training_utils/make_forest_tf_records.py @@ -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 diff --git a/generator/ctrl/training_utils/training.py b/generator/ctrl/training_utils/training.py index 5402277..e439fdd 100644 --- a/generator/ctrl/training_utils/training.py +++ b/generator/ctrl/training_utils/training.py @@ -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)