Skip to content

Commit

Permalink
Updating a typo in TF doc
Browse files Browse the repository at this point in the history
Updated the line from if (y_pred_rank - y_true_rank != 1) or y_pred_shape[-1] == 1: to
if (y_pred_rank - y_true_rank == 1) or y_pred_shape[-1] == 1:
as the current behavior will squeeze the y_pred tensor even when it’s the same rank and shape as the y_pred tensor.
Fixes #62718

Please have a look at this and do the needful. Thank you!
  • Loading branch information
sushreebarsa authored Jan 4, 2024
1 parent 6f412b4 commit 2c605ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tf_keras/utils/losses_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def squeeze_or_expand_dimensions(y_pred, y_true=None, sample_weight=None):
y_true_rank = y_true_shape.ndims
if (y_true_rank is not None) and (y_pred_rank is not None):
# Use static rank for `y_true` and `y_pred`.
if (y_pred_rank - y_true_rank != 1) or y_pred_shape[-1] == 1:
if (y_pred_rank - y_true_rank == 1) or y_pred_shape[-1] == 1:
y_true, y_pred = remove_squeezable_dimensions(y_true, y_pred)
else:
# Use dynamic rank.
Expand Down

0 comments on commit 2c605ce

Please sign in to comment.