From 9b13e9ca5b124d06d23726b53dc80cc941bf103e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 3 Mar 2023 21:51:24 +0000 Subject: [PATCH] dlr: fixup argmax first --- aimodel/src/lib/ai/components/MetricSensitivity.py | 3 +-- aimodel/src/lib/ai/components/MetricSpecificity.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/aimodel/src/lib/ai/components/MetricSensitivity.py b/aimodel/src/lib/ai/components/MetricSensitivity.py index 4060d7c..5d711f6 100644 --- a/aimodel/src/lib/ai/components/MetricSensitivity.py +++ b/aimodel/src/lib/ai/components/MetricSensitivity.py @@ -3,11 +3,10 @@ import math import tensorflow as tf def sensitivity(y_true, y_pred): + 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) - y_pred = tf.math.argmax(y_pred, axis=-1) - recall = tf.keras.metrics.Recall() recall.update_state(y_true, y_pred) return recall.result() diff --git a/aimodel/src/lib/ai/components/MetricSpecificity.py b/aimodel/src/lib/ai/components/MetricSpecificity.py index 60b4599..05bf156 100644 --- a/aimodel/src/lib/ai/components/MetricSpecificity.py +++ b/aimodel/src/lib/ai/components/MetricSpecificity.py @@ -13,11 +13,10 @@ def specificity(y_pred, y_true): Returns: Specificity score """ + 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) - y_pred = tf.math.argmax(y_pred, axis=-1) - neg_y_true = 1 - y_true neg_y_pred = 1 - y_pred fp = K.sum(neg_y_true * y_pred)