Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

normalize rows in matrix numpy

def normalize_rows(x: numpy.ndarray):
    """
    function that normalizes each row of the matrix x to have unit length.

    Args:
     ``x``: A numpy matrix of shape (n, m)

    Returns:
     ``x``: The normalized (by row) numpy matrix.
    """
    return x/numpy.linalg.norm(x, ord=2, axis=1, keepdims=True)
Comment

PREVIOUS NEXT
Code Example
Python :: sort column with numeric and text data 
Python :: print random word python 
Python :: loop rought rows in pands 
Python :: dataframe split column 
Python :: python check version 
Python :: np.concatenate 
Python :: sys get current pythonpath 
Python :: make pandas df from np array 
Python :: panda check a cell value is not a number 
Python :: get all values of a dict python 
Python :: remove n string 
Python :: find absolut vale in python 
Python :: join two numpy arrays 
Python :: tkinter app icon 
Python :: activate venv enviroment 
Python :: python read lines from text file 
Python :: password combination python 
Python :: how to pick a random english word from a list 
Python :: deleting duplicates in list python 
Python :: default argument in flask route 
Python :: polyfit python 
Python :: python how to make something run once 
Python :: scaling image interpolation python 
Python :: how to slice dataframe based on daterange in pandas 
Python :: python show only 1st element of nested lists 
Python :: remove nana from np array 
Python :: python colorama example 
Python :: click link selenium python 
Python :: convert mb to gb python 
Python :: set select group of columns to numeric pandas 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =