linalg.norm does not accept the axis argument. You can get around this with:
np.apply_along_axis(np.linalg.norm, 1, c) # array([ 3.74165739, 4.24264069])
Or, to be faster, do it yourself:
np.sqrt(np.einsum('ij,ij->i',c,c))
To sync:
timeit np.apply_along_axis(np.linalg.norm, 1, c) 10000 loops, best of 3: 170 ยตs per loop timeit np.sqrt(np.einsum('ij,ij->i',c,c)) 100000 loops, best of 3: 10.7 ยตs per loop
askewchan
source share