From cf2ae20e897fee7fcf459d00a19b5db6e14b1802 Mon Sep 17 00:00:00 2001 From: nickwalton Date: Wed, 23 Oct 2019 09:28:05 -0600 Subject: [PATCH] update --- generator/ctrl/ctrl_generator.py | 2 +- generator/ctrl/training_utils/training.py | 6 ++++-- story/utils.py | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index e15ca99..4e48619 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -20,7 +20,7 @@ def loss(labels, logits): class CTRLGenerator(): - def __init__(self, control_code="Writing Text: ", generate_num=64, temperature=0.5, topk=40): + def __init__(self, control_code="Writing Text: ", generate_num=64, temperature=0.3, topk=40): self.generate_num=generate_num model_dir = "generator/ctrl/training_utils/seqlen512_v1.ckpt/" diff --git a/generator/ctrl/training_utils/training.py b/generator/ctrl/training_utils/training.py index 734d4e3..10701c5 100644 --- a/generator/ctrl/training_utils/training.py +++ b/generator/ctrl/training_utils/training.py @@ -134,8 +134,10 @@ model = tf.keras.Model(inputs=tokens, outputs=logits) # the loss function is a simple categorical crossentropy between the logits and the labels def loss(labels, logits): loss = tf.keras.losses.sparse_categorical_crossentropy(labels, logits, from_logits=True) - loss = tf.Print(loss, [loss]) - return loss + sum = tf.math.reduce_sum(loss) + print_op = tf.Print(sum, [sum]) + with tf.control_dependencies([print_op]): + return loss # the optimizer is not used since this code only supports inference diff --git a/story/utils.py b/story/utils.py index a6fa4a6..3385513 100644 --- a/story/utils.py +++ b/story/utils.py @@ -1,3 +1,4 @@ +# coding: utf-8 import re import yaml @@ -104,6 +105,8 @@ def mapping_variation_pairs(mapping): first_to_second_mappings = [ ("I'm", "you're"), + ("Im", "you're"), + ("Ive", "you've"), ("I am", "you are"), ("I", "you"), ("I've", "you've"),