numpy中求解范数(numpy.linalg.norm)以及各阶范数详解 | np linalg norm keepdims
numpy.linalg.norm语法numpy.linalg.norm(x,ord=None,axis=None,keepdims=False)ParametersInputarray.IfaxisisNone,xmustbe1-Dor2-D,unlessordisNone.IfbothaxisandordareNone,the2-normofx.ravelwillbereturned.X是输入的array,array的情况必须是以下三种情况之一:axis未指定,ord指定。此时x必须是一维或二维数组axis指定,x任意axis未指定,ord未指定,此时x任意,返回值为x被展平后的一维向量x.ravel的二范数。ord:{non-zeroint,inf,-inf,‘fro’,‘nuc’},optionalOrderofthenorm(seetableunderNotes).infmeansnumpy’sinfobject.Th...
numpy.linalg.norm 语法numpy.linalg.norm(x,ord=None,axis=None,keepdims=False)
ParametersInput array. If axis is None, x must be 1-D or 2-D, unless ord is None. If both axis and ord are None, the 2-norm of x.ravel will be returned.
X是输入的array, array的情况必须是以下三种情况之一:
axis未指定,ord指定。此时x必须是一维或二维数组axis指定,x任意axis未指定,ord未指定,此时x任意,返回值为x被展平后的一维向量x.ravel的二范数。ord:{non-zero int, inf, -inf, ‘fro’, ‘nuc’}, optionalOrder of the norm (see table under Notes). inf means numpy’s inf object. The default is None.
范数的阶数,可以不指定。默认为None。inf代表无穷大,-inf为无穷小。可选的阶数见下图:
axis:{None, int, 2-tuple of ints},optionalIf axis is an integer, it specifies the axis of x along which to compute the vector norms. If axis is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If axis is None then either a vector norm (when x is 1-D) or a matrix norm (when x is 2-D) is returned. The default...