Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Convert inputs to tensor
  • Loading branch information
WindQAQ committed Aug 21, 2020
commit 41e5269f720c5056dd6a5ebec9c22bb45a8c6b19
7 changes: 4 additions & 3 deletions tensorflow_addons/losses/triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def triplet_semihard_loss(
Returns:
triplet_loss: float scalar with dtype of `y_pred`.
"""

labels, embeddings = y_true, y_pred
labels = tf.convert_to_tensor(y_true, name="labels")
embeddings = tf.convert_to_tensor(y_pred, name="embeddings")

convert_to_float32 = (
embeddings.dtype == tf.dtypes.float16 or embeddings.dtype == tf.dtypes.bfloat16
Expand Down Expand Up @@ -242,7 +242,8 @@ def triplet_hard_loss(
Returns:
triplet_loss: float scalar with dtype of `y_pred`.
"""
labels, embeddings = y_true, y_pred
labels = tf.convert_to_tensor(y_true, name="labels")
embeddings = tf.convert_to_tensor(y_pred, name="embeddings")

convert_to_float32 = (
embeddings.dtype == tf.dtypes.float16 or embeddings.dtype == tf.dtypes.bfloat16
Expand Down