Skip to content

Commit

Permalink
Updating for working metrics in Dawn, unsure why there was an issue o…
Browse files Browse the repository at this point in the history
…riginally
  • Loading branch information
JimCircadian committed May 10, 2024
1 parent 2c33c85 commit 6158908
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions icenet/model/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions icenet/model/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 6158908

Please sign in to comment.