For example, to normalize each row in a 2-dimensional vector such that the magnitude of a row is one:
import numpy as np
a = np.arange(0,27,3).reshape(3,3)
result = a / norm_of_rows( a )
Such that:
np.sum( result**2, axis=-1 )
# array([ 1., 1., 1.])
The original question, How to normalize a 2-dimensional numpy array in python less verbose?, which people feel my question is a duplicate of, the author actually asks how to make the elements of each row sum to one. This is different than normalizing each row such that its magnitude is one (the sum of the square of each element equals one).