norm¶
dragon.vm.torch.
norm
(
input,
p='fro',
dim=None,
keepdim=False,
out=None,
dtype=None
)[source]¶Compute the norm value of elements along the given dimension.
dim
could be negative orNone
:x = torch.tensor([[1., 2., 3.], [4., 5., 6.]]) # A negative dimension is the last-k axis print(torch.norm(x, dim=1)) print(torch.norm(x, dim=-1)) # Equivalent # If ``dim`` is None, the vector-style reduction # will be applied to return a scalar result print(torch.norm(x)) # 9.539 # Also, ``dim`` could be a sequence of integers print(torch.norm(x, dim=(0, 1))) # 9.539
- Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- p ({'fro', 1, 2}, optional) – The norm order.
- dim (Union[int, Sequence[int]], optional) – The dimension to reduce.
- keepdim (bool, optional, default=False) – Keep the reduced dimension or not.
- out (dragon.vm.torch.Tensor, optional) – The output tensor.
- dtype (str, optional) – The data type to cast to.
- Returns:
dragon.vm.torch.Tensor – The output tensor.