Skip to content

Commit

Permalink
Fix #239. SimSiam margin should be float not tf.constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
owenvallis committed Jun 13, 2022
1 parent 60e7c7b commit 7e877fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tensorflow_similarity/losses/simsiam.py
Expand Up @@ -70,7 +70,7 @@ def __init__(
"""
super().__init__(reduction=reduction, name=name, **kwargs)
self.projection_type = projection_type
self.margin = tf.constant([margin])
self.margin = margin

if self.projection_type == "negative_cosine_sim":
self._projection = negative_cosine_sim
Expand Down Expand Up @@ -108,7 +108,7 @@ def call(
per_example_projection = self._projection(cosine_simlarity)

# 1D tensor
loss: FloatTensor = per_example_projection * tf.constant([0.5]) + self.margin
loss: FloatTensor = per_example_projection * 0.5 + self.margin

return loss

Expand Down

0 comments on commit 7e877fe

Please sign in to comment.