Tensor Back End.Cosine Similarity Method
Definition
Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.1
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.1
Overload List
Cosine | Computes the cosine similarity of the corresponding elements of two tensors. |
Cosine | Computes the cosine similarity of the corresponding elements of two tensors. |
CosineSimilarity<T>(Tensor<T>, Tensor<T>, Tensor<Boolean>, Boolean)
Computes the cosine similarity of the corresponding elements of two tensors.
public virtual T CosineSimilarity<T>(
Tensor<T> tensor1,
Tensor<T> tensor2,
Tensor<bool>? mask = null,
bool skipMissingValues = false
)
Parameters
- tensor1 Tensor<T>
- The tensor that serves as the first operand.
- tensor2 Tensor<T>
- The tensor that serves as the second operand.
- mask Tensor<Boolean> (Optional)
- Optional. A boolean that specifies for which elements the operation should be performed. If null (the default), the operation is applied everywhere.
- skipMissingValues Boolean (Optional)
- Optional. Specifies whether missing values should be excluded from the aggregation. The default is false.
Type Parameters
- T
- The type of the elements of the tensors.
Return Value
TA tensor containing the cosine similarity of the elements of tensor1 and tensor2 that satisfy mask along the specified axis.
CosineSimilarity<T>(Tensor<T>, Tensor<T>, Axes, Tensor<T>, Boolean, Tensor<Boolean>, Boolean, TensorElementOrder)
Computes the cosine similarity of the corresponding elements of two tensors.
public virtual Tensor<T> CosineSimilarity<T>(
Tensor<T> tensor1,
Tensor<T> tensor2,
Axes axis,
Tensor<T>? result = null,
bool keepDimensions = false,
Tensor<bool>? mask = null,
bool skipMissingValues = false,
TensorElementOrder order = TensorElementOrder.Automatic
)
Parameters
- tensor1 Tensor<T>
- The tensor that serves as the first operand.
- tensor2 Tensor<T>
- The tensor that serves as the second operand.
- axis Axes
- The axis along which the cosine similarity of the elements is computed.
- result Tensor<T> (Optional)
- Optional. The tensor that is to hold the result. May be null.
- keepDimensions Boolean (Optional)
- Optional. Specifies whether the reduced axis should be retained in the result. The default is false.
- mask Tensor<Boolean> (Optional)
- Optional. A boolean tensor that specifies for which elements should be included in the operation. If null (the default), the operation is applied everywhere.
- skipMissingValues Boolean (Optional)
- Optional. Specifies whether missing values should be excluded from the operation. The default is false.
- order TensorElementOrder (Optional)
- Optional. If result is null, the desired ordering in memory of the result.
Type Parameters
- T
- The type of the elements of the tensors.
Return Value
Tensor<T>A tensor containing the cosine similarity of the elements of tensor1 and tensor2 that satisfy mask along the specified axis.
Exceptions
Argument | tensor1 is null. -or- tensor2 is null. |