2

i was trying to normalize a vector in python using numpy. I did the following:

matrix_norm = numpy.linalg.norm(matrix1[:,0], ord='fro')
print(matrix_norm)

The matrix1 is of size: 1000 X 1400. I tried find the normalization value for the first column of the matrix. And it gives me the following exception:

"Invalid norm order for vectors"

Please help ! Thanks in advance... :)

1 Answer 1

6

ord='fro' is the Frobenius norm (https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.norm.html) and in numpy it is considered an invalid for vector norms (see https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.norm.html). If you want the 2-norm for vectors, just drop ord:

norm_of_first_column = numpy.linalg.norm(matrix1[:,0])
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you soo much, brother ! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.