西安市人民代表大会常务委员会公告[十五届]第91..

paddle.linalg. matrix_norm ( x: Tensor, p: float | _POrder = 'fro', axis: int | list[int] | tuple[int, int] = [-2, -1], keepdim: bool = False, name: str | None = None ) Tensor [source]
百度 其中小白组因为有各种舞风的舞者,练习时就状况连连,最后上台更是惨不忍睹,几乎每个人都忘记一部分的舞步,整体跳起来零零落落,让黄子韬忍不住发脾气怒骂:你们真的让我太失望了!韩庚一度想要灭火,立刻被黄子韬阻止,你让我讲完好吗,哥!小白组在练习时,就发生许多状况,有些人跟不上,有的人因为太累舞步记不得,小白让大家睡2小时后,状况稍稍好转一些。

Calculate the p-order matrix norm for certain dimension of Tensor input.

Parameters
  • x (Tensor) – Tensor, data type float32, float64.

  • p (int|float|string, optional) – Default ‘fro’.

  • axis (int|list|tuple, optional) – The axis is a list(int)/tuple(int) with two elements. Default last two dimensions.

  • keepdim (bool, optional) – Whether keep the dimensions as the input, Default False.

  • name (str|None, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

results of matrix_norm operation on the specified axis of input tensor, it’s data type is the same as input’s Tensor.

Return type

Tensor

Examples

>>> import paddle
>>> x = paddle.arange(24, dtype="float32").reshape([2, 3, 4]) - 12
>>> print(x)
Tensor(shape=[2, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[-12., -11., -10., -9. ],
  [-8. , -7. , -6. , -5. ],
  [-4. , -3. , -2. , -1. ]],
 [[ 0. ,  1. ,  2. ,  3. ],
  [ 4. ,  5. ,  6. ,  7. ],
  [ 8. ,  9. ,  10.,  11.]]])

>>> out_matrix_norm = paddle.linalg.matrix_norm(x=x,p=2,axis=[0,1],keepdim=False)
>>> print(out_matrix_norm)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[15.75857544, 14.97978878, 14.69693947, 14.97978973])

>>> out_matrix_norm = paddle.linalg.matrix_norm(x=x,p='fro',axis=[0,1],keepdim=False)
>>> print(out_matrix_norm)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[17.43559647, 16.91153526, 16.73320007, 16.91153526])

>>> out_matrix_norm = paddle.linalg.matrix_norm(x=x,p=float('inf'),axis=[1,2],keepdim=False)
>>> print(out_matrix_norm)
Tensor(shape=[2], dtype=float32, place=Place(cpu), stop_gradient=True,
[42., 38.])

>>> out_matrix_norm = paddle.linalg.matrix_norm(x=x,p=-1,axis=[0,1],keepdim=False)
>>> print(out_matrix_norm)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[12., 12., 12., 12.])

>>> out_matrix_norm = paddle.linalg.matrix_norm(x=x,p='nuc',axis=[0,1],keepdim=False)
>>> print(out_matrix_norm)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[23.21962357, 22.82873154, 22.69693947, 22.82873154])