mindsponge.common.vecs_robust_normalize

View Source On Gitee
mindsponge.common.vecs_robust_normalize(v, epsilon=1e-08)[source]

Use l2-norm normalization vectors

\[\begin{split}\begin{split} &v=(x1,x2,x3) \\ &l2\_norm=\sqrt{x1*x1+x2*x2+x3*x3+epsilon} \\ &result=(x1/l2\_norm, x2/l2\_norm, x3/l2\_norm) \\ \end{split}\end{split}\]
Parameters
  • v (Tuple) – Input vector \((x,y,z)\) . Data type is scalar or Tensor with same shape.

  • epsilon (float) – Minimal value, prevent the result from being 0. Default: 1e-8.

Returns

Tuple with length of 3, normalized 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_normalize
>>> x= Tensor(np.ones(256), mstype.float32)
>>> y= Tensor(np.ones(256), mstype.float32)
>>> z= Tensor(np.ones(256), mstype.float32)
>>> result=vecs_robust_normalize((x,y,z))
>>> print(len(result))
>>> print(result[0].shape)
>>> print(result[1].shape)
>>> print(result[2].shape)
    3
(256,)
(256,)
(256,)