Skip to content

Commit

Permalink
test loss function
Browse files Browse the repository at this point in the history
  • Loading branch information
Arno1235 committed Mar 22, 2023
1 parent bab0814 commit 5c19b31
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions unet_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,19 +343,9 @@ def get_loss(self, logits, labels):
flat_pred = tf.reshape(pred, [-1, self.n_class])

# dice
eps = 1e-5
intersection = tf.reduce_sum(flat_pred * flat_labels, axis=0)
sum_ = eps + tf.reduce_sum(flat_pred + flat_labels, axis=0)
dice = 2 * intersection / sum_

loss = len(dice)
for d in dice:
loss -= d
# loss /= len(dice)
# loss = 1-loss
loss *= 1_000_000

# print(f'TEST loss: {loss}, dice: {dice}')
sum_ = tf.reduce_sum(flat_pred + flat_labels, axis=0)
loss = 1.0 - 2.0 * (intersection + 1) / (sum_ + 1)

### TEST ###

Expand Down

0 comments on commit 5c19b31

Please sign in to comment.