You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.CosineSimilarity.rst 976 B

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