From bc734a29c668c3ef32f9d11a68dc9c53c17f9219 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 3 Mar 2023 22:20:11 +0000 Subject: [PATCH] y_true is one-hot, convert to sparse --- aimodel/src/lib/ai/components/MetricMeanIoU.py | 1 + aimodel/src/lib/ai/components/MetricSensitivity.py | 1 + aimodel/src/lib/ai/components/MetricSpecificity.py | 1 + 3 files changed, 3 insertions(+) diff --git a/aimodel/src/lib/ai/components/MetricMeanIoU.py b/aimodel/src/lib/ai/components/MetricMeanIoU.py index 1fa2947..b1b2dfb 100644 --- a/aimodel/src/lib/ai/components/MetricMeanIoU.py +++ b/aimodel/src/lib/ai/components/MetricMeanIoU.py @@ -14,6 +14,7 @@ def one_hot_mean_iou(y_true, y_pred, classes=2): """ y_pred = tf.math.argmax(y_pred, axis=-1) + y_true = tf.math.argmax(y_true, axis=-1) y_true = tf.cast(y_true, dtype=tf.float32) y_pred = tf.cast(y_pred, dtype=tf.float32) diff --git a/aimodel/src/lib/ai/components/MetricSensitivity.py b/aimodel/src/lib/ai/components/MetricSensitivity.py index 5d711f6..ce9f359 100644 --- a/aimodel/src/lib/ai/components/MetricSensitivity.py +++ b/aimodel/src/lib/ai/components/MetricSensitivity.py @@ -4,6 +4,7 @@ import tensorflow as tf def sensitivity(y_true, y_pred): y_pred = tf.math.argmax(y_pred, axis=-1) + y_true = tf.math.argmax(y_true, axis=-1) y_true = tf.cast(y_true, dtype=tf.float32) y_pred = tf.cast(y_pred, dtype=tf.float32) diff --git a/aimodel/src/lib/ai/components/MetricSpecificity.py b/aimodel/src/lib/ai/components/MetricSpecificity.py index b15bef9..e2fa021 100644 --- a/aimodel/src/lib/ai/components/MetricSpecificity.py +++ b/aimodel/src/lib/ai/components/MetricSpecificity.py @@ -14,6 +14,7 @@ def specificity(y_pred, y_true): Specificity score """ y_pred = tf.math.argmax(y_pred, axis=-1) + y_true = tf.math.argmax(y_true, axis=-1) y_true = tf.cast(y_true, dtype=tf.float32) y_pred = tf.cast(y_pred, dtype=tf.float32)