cosine
Functions:
| Name | Description | 
|---|---|
| normalized_cosine_distance | Calculate the cosine distance (negative cosine similarity) between two tensors, scaled and shifted into the range [0, 1]. | 
| normalized_cosine_similarity | Calculate the cosine similarity between two tensors, scaled and shifted into the range [0, 1]. | 
absolute_cosine_similarity(
    x0: Tensor, x1: Tensor, noise_mask: Tensor | None = None
) -> torch.Tensor
Calculate the absolute cosine similarity between two tensors, masked by a noise mask.
When used as a loss it encourages the two tensors to be orthogonal.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | Tensor | The first tensor. | required | 
|                    | Tensor | The second tensor. | required | 
|                    | Tensor | None | A boolean mask indicating which elements to include in the calculation. | None | 
Returns:
| Type | Description | 
|---|---|
| torch.Tensor | The mean absolute cosine similarity between the two tensors, masked by the noise mask. | 
normalized_cosine_distance(
    x1: Tensor, x2: Tensor, dim: int = 1, eps: float = 1e-08
) -> torch.Tensor
Calculate the cosine distance (negative cosine similarity) between two tensors, scaled and shifted into the range [0, 1].
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | Tensor | The first tensor. | required | 
|                    | Tensor | The second tensor. | required | 
|                    | int | The dimension along which cosine distance is computed. | 1 | 
|                    | float | A small value to prevent division by zero. | 1e-08 | 
Returns:
| Type | Description | 
|---|---|
| torch.Tensor | The cosine distance of the tensors, scaled and shifted to between 0 and 1. | 
Added in version 0.82.0.
normalized_cosine_similarity(
    x1: Tensor, x2: Tensor, dim: int = 1, eps: float = 1e-08
) -> torch.Tensor
Calculate the cosine similarity between two tensors, scaled and shifted into the range [0, 1].
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | Tensor | The first tensor. | required | 
|                    | Tensor | The second tensor. | required | 
|                    | int | The dimension along which cosine similarity is computed. | 1 | 
|                    | float | A small value to prevent division by zero. | 1e-08 | 
Returns:
| Type | Description | 
|---|---|
| torch.Tensor | The cosine similarity of the tensors, scaled and shifted to between 0 and 1. | 
Added in version 0.82.0.