r"""Calculates the maximum of tensor elements over a given axis (or axes). Args: inp: input tensor. Should have a numeric data type. axis: axis or axes along which maximums must be computed. By default, the maximum must be computed over the entire tensor.
(
inp: Tensor,
axis: Optional[Union[int, Sequence[int]]] = None,
keepdims: bool = False,
)
| 438 | |
| 439 | |
| 440 | def max( |
| 441 | inp: Tensor, |
| 442 | axis: Optional[Union[int, Sequence[int]]] = None, |
| 443 | keepdims: bool = False, |
| 444 | ) -> Tensor: |
| 445 | r"""Calculates the maximum of tensor elements over a given axis (or axes). |
| 446 | |
| 447 | Args: |
| 448 | inp: input tensor. Should have a numeric data type. |
| 449 | axis: axis or axes along which maximums must be computed. |
| 450 | By default, the maximum must be computed over the entire tensor. |
| 451 | If a sequence of integers, maximums must be computed over multiple axes. |
| 452 | keepdims: if ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions, |
| 453 | and, accordingly, the result must be compatible with the input tensor (see :ref:`broadcasting-rule`). |
| 454 | Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result. |
| 455 | |
| 456 | Returns: |
| 457 | if the maximum was computed over the entire tensor, a zero-dimensional tensor containing the maximum; |
| 458 | otherwise, a non-zero-dimensional tensor containing the maximums. |
| 459 | |
| 460 | .. admonition:: Special Cases |
| 461 | |
| 462 | If :math:`x_i` is ``NaN``, the maximum is ``NaN`` (i.e., ``NaN`` values propagate). |
| 463 | |
| 464 | Examples: |
| 465 | |
| 466 | >>> x = Tensor([[1, 2], [3, 4]]) |
| 467 | >>> F.max(x) |
| 468 | Tensor(4, dtype=int32, device=xpux:0) |
| 469 | |
| 470 | Along an axis: |
| 471 | |
| 472 | >>> F.max(x, axis=0) |
| 473 | Tensor([3 4], dtype=int32, device=xpux:0) |
| 474 | >>> F.max(x, axis=1) |
| 475 | Tensor([2 4], dtype=int32, device=xpux:0) |
| 476 | """ |
| 477 | return inp.max(axis=axis, keepdims=keepdims) |
| 478 | |
| 479 | |
| 480 | # searching functions |