Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing L2-norm in contrastive loss (L2-norm already present in CosS…
…im) (#6550) ### Description The `forward` method of the `ContrastiveLoss` performs L2-normalization before computing cosine similarity. The [`torch.nn.functional.cosine_similarity`](https://pytorch.org/docs/stable/generated/torch.nn.functional.cosine_similarity.html) method already handles this pre-processing to make sure that `input` and `target` lie on the surface of the unit hypersphere. This step involves an unnecessary cost and, thus, can be removed. ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. Signed-off-by: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
- Loading branch information