normalize¶
- normalize(data: Tensor, order: int | float, scale: float | complex = 1.0, dim: int | tuple[int, ...] | None = None, epsilon: float = 1e-12) Tensor[source]¶
Normalizes a tensor.
- Parameters:
data (torch.Tensor) – data to normalize.
order (int | float) – order of \(p\)-norm by which to normalize.
scale (float | complex, optional) – desired \(p\)-norm of elements along specified dimensions. Defaults to
1.0.dim (int | tuple[int, ...] | None, optional) – dimension(s) along which to normalize, all dimensions if
None. Defaults toNone.epsilon (float, optional) – value added to the denominator in case of zero-valued norms. Defaults to
1e-12.
- Returns:
normalized tensor.
- Return type: