Advertisement
Korotkodul

Часть 3. Далеко ли, близко ли?

Feb 17th, 2025 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def get_mutual_l2_distances_vectorized(
  4.     lhs: np.ndarray,
  5.     rhs: np.ndarray,
  6. ) -> np.ndarray:
  7.     res = np.sqrt(np.sum( (lhs[:, np.newaxis, :] - rhs[np.newaxis, :, :]) ** 2, axis = 2 ))
  8.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement