Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dice_loss(onehots_true, logits):
- probabilities = tf.nn.softmax(logits)
- #weights = 1.0 / ((tf.reduce_sum(onehots_true, axis=0)**2) + 1e-3)
- #weights = tf.clip_by_value(weights, 1e-17, 1.0 - 1e-7)
- numerator = tf.reduce_sum(onehots_true * probabilities, axis=0)
- #numerator = tf.reduce_sum(weights * numerator)
- denominator = tf.reduce_sum(onehots_true + probabilities, axis=0)
- #denominator = tf.reduce_sum(weights * denominator)
- loss = 1.0 - 2.0 * (numerator + 1) / (denominator + 1)
- return loss
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement