This commit is contained in:
Starbeamrainbowlabs 2023-03-03 22:39:30 +00:00
parent 5472729f5e
commit 750f46dbd2
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 12 additions and 1 deletions

View file

@ -12,10 +12,13 @@ def one_hot_mean_iou(y_true, y_pred, classes=2):
Returns:
tf.Tensor: The computed mean IoU.
"""
print("DEBUG:meaniou y_pred.shape BEFORE", y_pred.shape)
print("DEBUG:meaniou y_true.shape BEFORE", y_true.shape)
y_pred = tf.math.argmax(y_pred, axis=-1)
y_true = tf.cast(y_true, dtype=tf.float32)
y_pred = tf.cast(y_pred, dtype=tf.float32)
print("DEBUG:meaniou y_pred.shape AFTER", y_pred.shape)
print("DEBUG:meaniou y_true.shape AFTER", y_true.shape)
iou = tf.keras.metrics.MeanIoU(num_classes=classes)

View file

@ -3,9 +3,13 @@ import math
import tensorflow as tf
def sensitivity(y_true, y_pred):
print("DEBUG:sensitivity y_pred.shape BEFORE", y_pred.shape)
print("DEBUG:sensitivity y_true.shape BEFORE", y_true.shape)
y_pred = tf.math.argmax(y_pred, axis=-1)
y_true = tf.cast(y_true, dtype=tf.float32)
y_pred = tf.cast(y_pred, dtype=tf.float32)
print("DEBUG:sensitivity y_pred.shape AFTER", y_pred.shape)
print("DEBUG:sensitivity y_true.shape AFTER", y_true.shape)
recall = tf.keras.metrics.Recall()
recall.update_state(y_true, y_pred)

View file

@ -13,9 +13,13 @@ def specificity(y_true, y_pred):
Returns:
Specificity score
"""
print("DEBUG:specificity y_pred.shape BEFORE", y_pred.shape)
print("DEBUG:specificity y_true.shape BEFORE", y_true.shape)
y_pred = tf.math.argmax(y_pred, axis=-1)
y_true = tf.cast(y_true, dtype=tf.float32)
y_pred = tf.cast(y_pred, dtype=tf.float32)
print("DEBUG:specificity y_pred.shape AFTER", y_pred.shape)
print("DEBUG:specificity y_true.shape AFTER", y_true.shape)
neg_y_true = 1 - y_true
neg_y_pred = 1 - y_pred