Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix CosineEmbeddingLoss in when symbol API is used (#17308)
Browse files Browse the repository at this point in the history
* Fix CosineEmbeddingLoss in when symbol API is used

Fixes #17275

* Update CONTRIBUTORS.md
  • Loading branch information
dithyrambe authored and szha committed Jan 15, 2020
1 parent 71e70f2 commit 05a0e5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ List of Contributors
* [Disi A](https://github.com/adis300)
* [Vandana Kannan](https://github.com/vandanavk)
* [Guanxin Qiao](https://github.com/guanxinq)
* [dithyrambe](https://github.com/dithyrambe)

Label Bot
---------
Expand Down
6 changes: 3 additions & 3 deletions python/mxnet/gluon/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,9 @@ def hybrid_forward(self, F, input1, input2, label, sample_weight=None):

def _cosine_similarity(self, F, x, y, axis=-1):
# Calculates the cosine similarity between 2 vectors
x_norm = F.norm(x, axis=axis).reshape(-1, 1)
y_norm = F.norm(y, axis=axis).reshape(-1, 1)
x_dot_y = F.sum(x * y, axis=axis).reshape(-1, 1)
x_norm = F.norm(x, axis=axis).reshape((-1, 1))
y_norm = F.norm(y, axis=axis).reshape((-1, 1))
x_dot_y = F.sum(x * y, axis=axis).reshape((-1, 1))
if F is ndarray:
eps_arr = F.array([1e-12])
else:
Expand Down

0 comments on commit 05a0e5b

Please sign in to comment.