SHARE
TWEET

Python - mumpy apply_along_axis

furas Jun 5th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3. data_1 = np.array([[1], [2]])
  4. data_2 = np.array([[8], [9]])
  5.  
  6. for row1 in data_1:
  7.     f = lambda row2: np.linalg.norm(row2-row1)
  8.     distances = np.apply_along_axis(f, 1, data_2)
  9.     print(distances.min())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top