mindspore2022/docs/api/api_python/nn/mindspore.nn.CosineSimilari...

37 lines
976 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.nn.CosineSimilarity
=============================
.. py:class:: mindspore.nn.CosineSimilarity(similarity='cosine', reduction='none', zero_diagonal=True)
计算表示相似性。
**参数:**
- **similarity** (str) - "dot"或"cosine"。默认值:"cosine"。
- **reduction** (str) - "none"、"sum"或"mean"。默认值:"none"。
- **zero_diagonal** (bool) - 如果为True则对角线将设置为零。默认值True。
.. py:method:: clear()
重置评估结果。
.. py:method:: eval()
计算Cosine Similarity矩阵。
**返回:**
numpy.ndarray相似度矩阵。
**异常:**
- **RuntimeError** - 如果没有先调用update方法。
.. py:method:: update(*inputs)
使用y_pred和y更新内部评估结果。
**参数:**
- **inputs** (Union[Tensor, list, numpy.ndarray]) - 输入的矩阵。