To normalize the rows of a matrix X to unit length, I usually proceed as follows:
X
X /= np.linalg.norm(X, axis=1, keepdims=True)