This commit is contained in:
nickwalton
2019-10-23 09:28:05 -06:00
parent 7bad170add
commit cf2ae20e89
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -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/"
+4 -2
View File
@@ -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
+3
View File
@@ -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"),