np.linalg.norm
时间: 2023-11-02 12:29:55 浏览: 54
numpy基础教程之np.linalg
np.linalg.norm calculates the norm of a vector or matrix using various techniques. It returns the square root of the sum of squares of all the elements of the vector or matrix.
Syntax:
np.linalg.norm(x, ord=None, axis=None, keepdims=False)
Parameters:
- x: The input array, which could be a vector or matrix.
- ord: The order of the norm. It can have the following values:
- None: It is the default value and calculates the Frobenius norm of a matrix or the L2 norm of a vector.
- 1: Calculates the L1 norm of a vector or matrix.
- 2: Calculates the L2 norm of a vector or matrix.
- inf: Calculates the L infinity norm of a vector or matrix.
- axis: The axis along which the norm is to be computed. It can have the following values:
- None: Calculates the norm of the flattened array.
- 0: Calculates the norm of each column.
- 1: Calculates the norm of each row.
- keepdims: It is a boolean value that specifies whether to keep the dimensions of the original array or not.
Returns:
The norm of the input array.
阅读全文