Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. def dice_loss(onehots_true, logits):
  2. probabilities = tf.nn.softmax(logits)
  3. #weights = 1.0 / ((tf.reduce_sum(onehots_true, axis=0)**2) + 1e-3)
  4. #weights = tf.clip_by_value(weights, 1e-17, 1.0 - 1e-7)
  5. numerator = tf.reduce_sum(onehots_true * probabilities, axis=0)
  6. #numerator = tf.reduce_sum(weights * numerator)
  7. denominator = tf.reduce_sum(onehots_true + probabilities, axis=0)
  8. #denominator = tf.reduce_sum(weights * denominator)
  9. loss = 1.0 - 2.0 * (numerator + 1) / (denominator + 1)
  10. return loss
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement