Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def get_mutual_l2_distances_vectorized(
- lhs: np.ndarray,
- rhs: np.ndarray,
- ) -> np.ndarray:
- res = np.sqrt(np.sum( (lhs[:, np.newaxis, :] - rhs[np.newaxis, :, :]) ** 2, axis = 2 ))
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement