From 6158908999762744f59af35fa959cfb8d26c6385 Mon Sep 17 00:00:00 2001 From: James Byrne Date: Fri, 10 May 2024 11:27:54 +0100 Subject: [PATCH] Updating for working metrics in Dawn, unsure why there was an issue originally --- icenet/model/losses.py | 6 ++++-- icenet/model/metrics.py | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/icenet/model/losses.py b/icenet/model/losses.py index 3b0f360..f070c06 100644 --- a/icenet/model/losses.py +++ b/icenet/model/losses.py @@ -24,9 +24,11 @@ def __call__(self, # TF automatically reduces along final dimension - include dummy axis y_true = tf.expand_dims(y_true, axis=-1) y_pred = tf.expand_dims(y_pred, axis=-1) + #tf.print(y_true.shape, y_pred.shape)#, sample_weight.shape) + #tf.print(type(y_true), type(y_pred))#, type(sample_weight)) - y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) - y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) + #y_true = tf.where(sample_weight == 0., tf.zeros_like(y_true), y_true) + #y_pred = tf.where(sample_weight == 0., tf.zeros_like(y_pred), y_pred) return super().__call__(100 * y_true, 100 * y_pred, diff --git a/icenet/model/metrics.py b/icenet/model/metrics.py index 3438b05..b4c2b53 100644 --- a/icenet/model/metrics.py +++ b/icenet/model/metrics.py @@ -193,8 +193,8 @@ def update_state(self, if sample_weight is not None and sample_weight.shape[-1] != 1: sample_weight = tf.expand_dims(sample_weight, axis=-1) - y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) - y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) + #y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) + #y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) return super().update_state(y_true, y_pred, sample_weight=sample_weight) def result(self): @@ -249,8 +249,8 @@ def update_state(self, if sample_weight is not None and sample_weight.shape[-1] != 1: sample_weight = tf.expand_dims(sample_weight, axis=-1) - y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) - y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) + #y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) + #y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) return super().update_state(y_true, y_pred, sample_weight=sample_weight) def result(self): @@ -304,8 +304,8 @@ def update_state(self, if sample_weight is not None and sample_weight.shape[-1] != 1: sample_weight = tf.expand_dims(sample_weight, axis=-1) - y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) - y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) + #y_true = tf.where(tf.math.is_nan(y_true), tf.zeros_like(y_true), y_true) + #y_pred = tf.where(tf.math.is_nan(y_pred), tf.zeros_like(y_pred), y_pred) return super().update_state(y_true, y_pred, sample_weight=sample_weight) def result(self):