Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. optimizer = tf.keras.optimizers.Adam()
  2. loss_object = tf.keras.losses.SparseCategoricalCrossentropy(
  3. from_logits=True, reduction='none')
  4.  
  5. def loss_function(real, pred):
  6. mask = tf.math.logical_not(tf.math.equal(real, 0))
  7. loss_ = loss_object(real, pred)
  8.  
  9. mask = tf.cast(mask, dtype=loss_.dtype)
  10. loss_ *= mask
  11.  
  12. return tf.reduce_mean(loss_)
  13.  
  14. checkpoint_dir = './training_checkpoints'
  15. checkpoint_prefix = os.path.join(checkpoint_dir, "ckpt")
  16. checkpoint = tf.train.Checkpoint(optimizer=optimizer,
  17. encoder=encoder,
  18. decoder=decoder)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement