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