norm

dragon.math.norm(
  inputs,
  ord=None,
  axis=None,
  keepdims=False,
  **kwargs
)[source]

Compute the norm value of elements along the given axis.

axis could be negative or None:

x = dragon.constant([[1., 2., 3.], [4., 5., 6.]])

# A negative axis is the last-k axis
print(dragon.math.norm(x, axis=1))
print(dragon.math.norm(x, axis=-1))  # Equivalent

# If ``axis`` is None, the vector-style reduction
# will be applied to return a scalar result
print(dragon.math.norm(x))  # 9.539

# Also, ``axis`` could be a sequence of integers
print(dragon.math.norm(x, axis=(0, 1)))  # 9.539
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • ord ({1, 2, 'fro'}, optional) – The norm order.
  • axis (Union[int, Sequence[int]], optional) – The axis to reduce.
  • keepdims (bool, optional, default=False) – Keep the reduced dimensions or not.
Returns:

dragon.Tensor – The output tensor.