CosineSimilarity
-
class torch.nn.CosineSimilarity(dim=1, eps=1e-08)[source] -
Возвращает косинусное сходство между и , вычисленное по
dim.- Параметры:
- Форма:
-
- Вход 1: , где D находится на позиции
dim -
-
Input2: (∗1,D,∗2)(\ast_1, D, \ast_2), same number of dimensions as x1, matching x1 size at dimension dim, -
и совместим с x1 по другим измерениям.
-
- Вывод:
- Вход 1: , где D находится на позиции
- Примеры::
-
>>> input1 = torch.randn(100, 128) >>> input2 = torch.randn(100, 128) >>> cos = nn.CosineSimilarity(dim=1, eps=1e-6) >>> output = cos(input1, input2)
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/1.13/generated/torch.nn.CosineSimilarity.html