mindsponge.common.vecs_robust_norm
- mindsponge.common.vecs_robust_norm(v, epsilon=1e-08)[source]
Calculate the l2-norm of a vector.
\[\begin{split}\begin{split} &v=(x1,x2,x3) \\ &l2\_norm=\sqrt{x1*x1+x2*x2+x3*x3+epsilon} \\ \end{split}\end{split}\]- Parameters
v (Tuple) – Input vector \((x,y,z)\) . Data type is scalar or Tensor with same shape.
epsilon (float) – A very small number to prevent the result from being 0. Default: 1e-8.
- Returns
Tensor, 2-Norm calculated by vector v. Shape is the same as v.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> from mindspore import dtype as mstype >>> from mindsponge.common.geometry import vecs_robust_norm >>> x= Tensor(np.ones(256), mstype.float32) >>> y= Tensor(np.ones(256), mstype.float32) >>> z= Tensor(np.ones(256), mstype.float32) >>> result=vecs_robust_norm((x,y,z)) >>> print(result.shape) (256)