Distance#
Pairwise Distance#
- cuvs.distance.pairwise_distance(
- X,
- Y,
- out=None,
- metric='euclidean',
- metric_arg=2.0,
- resources=None,
Compute pairwise distances between X and Y
- Valid values for metric:
- [“euclidean”, “l2”, “l1”, “cityblock”, “inner_product”,
“chebyshev”, “canberra”, “lp”, “hellinger”, “jensenshannon”, “kl_divergence”, “russellrao”, “minkowski”, “correlation”, “cosine”]
- Parameters:
- XCUDA array interface compliant matrix shape (m, k)
- YCUDA array interface compliant matrix shape (n, k)
- outOptional writable CUDA array interface matrix shape (m, n)
- metricstring denoting the metric type (default=”euclidean”)
- metric_argmetric parameter (currently used only for “minkowski”)
- resourcesOptional cuVS Resource handle for reusing CUDA resources.
If Resources aren’t supplied, CUDA resources will be allocated inside this function and synchronized before the function exits. If resources are supplied, you will need to explicitly synchronize yourself by calling
resources.sync()
before accessing the output.
Examples
>>> import cupy as cp >>> from cuvs.distance import pairwise_distance >>> n_samples = 5000 >>> n_features = 50 >>> in1 = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) >>> in2 = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) >>> output = pairwise_distance(in1, in2, metric="euclidean")