# tensorplay.nn.functional.cosine_similarity Source: https://www.tensorplay.cn/docs/generated/tensorplay.nn.functional.cosine_similarity.html ```python tensorplay.nn.functional.cosine_similarity(x1: Tensor, x2: Tensor, dim: int = 1, eps: float = 1e-08) → Tensor ``` Returns cosine similarity between x1 and x2, computed along dim. The inputs are normalized before the dot product, and the per-row norms are accumulated in a wider dtype (float32 for half-precision inputs, float64 for float32), so that squaring large values cannot overflow the accumulator and turn the result into NaN.