pe.histogram.nearest_neighbor_backend.torch module
- pe.histogram.nearest_neighbor_backend.torch.search(syn_embedding, priv_embedding, num_nearest_neighbors, mode)[source]
Compute the nearest neighbors of the private embedding in the synthetic embedding using torch.
- Parameters:
syn_embedding (np.ndarray) – The synthetic embedding
priv_embedding (np.ndarray) – The private embedding
num_nearest_neighbors (int) – The number of nearest neighbors to search
mode (str) – The distance metric to use for finding the nearest neighbors. Only “l2” (l2 distance) is currently supported
- Raises:
ValueError – If the mode is unknown
- Returns:
The distances and indices of the nearest neighbors
- Return type:
tuple[np.ndarray, np.ndarray]