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

Fix CosineEmbeddingLoss in when symbol API is used #17308

Merged
merged 2 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
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
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