Skip to content

Commit

Permalink
ops.square
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdangerw committed Nov 27, 2023
1 parent c5ad052 commit 73b40fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/nlp/ipynb/sentence_embeddings_with_sbert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@
" ep = encoder(positive)\n",
" en = encoder(negative)\n",
"\n",
" positive_dist = keras.ops.sum(keras.ops.power(ea - ep, 2), axis=1)\n",
" negative_dist = keras.ops.sum(keras.ops.power(ea - en, 2), axis=1)\n",
" positive_dist = keras.ops.sum(keras.ops.square(ea - ep), axis=1)\n",
" negative_dist = keras.ops.sum(keras.ops.square(ea - en), axis=1)\n",
"\n",
" positive_dist = keras.ops.sqrt(positive_dist)\n",
" negative_dist = keras.ops.sqrt(negative_dist)\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/nlp/md/sentence_embeddings_with_sbert.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ class TripletSiamese(keras.Model):
ep = encoder(positive)
en = encoder(negative)

positive_dist = keras.ops.sum(keras.ops.power(ea - ep, 2), axis=1)
negative_dist = keras.ops.sum(keras.ops.power(ea - en, 2), axis=1)
positive_dist = keras.ops.sum(keras.ops.square(ea - ep), axis=1)
negative_dist = keras.ops.sum(keras.ops.square(ea - en), axis=1)

positive_dist = keras.ops.sqrt(positive_dist)
negative_dist = keras.ops.sqrt(negative_dist)
Expand Down
4 changes: 2 additions & 2 deletions examples/nlp/sentence_embeddings_with_sbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ def __init__(self, encoder, **kwargs):
ep = encoder(positive)
en = encoder(negative)

positive_dist = keras.ops.sum(keras.ops.power(ea - ep, 2), axis=1)
negative_dist = keras.ops.sum(keras.ops.power(ea - en, 2), axis=1)
positive_dist = keras.ops.sum(keras.ops.square(ea - ep), axis=1)
negative_dist = keras.ops.sum(keras.ops.square(ea - en), axis=1)

positive_dist = keras.ops.sqrt(positive_dist)
negative_dist = keras.ops.sqrt(negative_dist)
Expand Down

0 comments on commit 73b40fd

Please sign in to comment.