Created
August 30, 2019 14:52
-
-
Save NMZivkovic/597ac27670510cffccb112eefdd4c83c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loss_objective_function = SparseCategoricalCrossentropy(from_logits=True, reduction='none') | |
def padded_loss_function(real, prediction): | |
mask = tf.math.logical_not(tf.math.equal(real, 0)) | |
loss = loss_objective_function(real, prediction) | |
mask = tf.cast(mask, dtype=loss.dtype) | |
loss *= mask | |
return tf.reduce_mean(loss) | |
training_loss = Mean(name='training_loss') | |
training_accuracy = SparseCategoricalAccuracy(name='training_accuracy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment