CosineSimilarity
-
class torch.nn.CosineSimilarity(dim=1, eps=1e-08)
[source] -
Returns cosine similarity between and , computed along dim.
- Parameters
- Shape:
-
- Input1: where D is at position
dim
- Input2: , same shape as the Input1
- Output:
- Input1: where D is at position
- Examples::
-
>>> input1 = torch.randn(100, 128) >>> input2 = torch.randn(100, 128) >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6) >>> output = cos(input1, input2)
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.nn.CosineSimilarity.html