`torch.min` with equivalent implementation for numpy Args: x: array/tensor. Returns: the minimum of x.
(x: NdarrayTensor, dim: int | tuple | None = None, **kwargs)
| 526 | |
| 527 | |
| 528 | def min(x: NdarrayTensor, dim: int | tuple | None = None, **kwargs) -> NdarrayTensor: |
| 529 | """`torch.min` with equivalent implementation for numpy |
| 530 | |
| 531 | Args: |
| 532 | x: array/tensor. |
| 533 | |
| 534 | Returns: |
| 535 | the minimum of x. |
| 536 | """ |
| 537 | |
| 538 | ret: NdarrayTensor |
| 539 | if dim is None: |
| 540 | ret = np.min(x, **kwargs) if isinstance(x, (np.ndarray, list)) else torch.min(x, **kwargs) # type: ignore |
| 541 | else: |
| 542 | if isinstance(x, (np.ndarray, list)): |
| 543 | ret = np.min(x, axis=dim, **kwargs) |
| 544 | else: |
| 545 | ret = torch.min(x, int(dim), **kwargs) # type: ignore |
| 546 | |
| 547 | return ret[0] if isinstance(ret, tuple) else ret |
| 548 | |
| 549 | |
| 550 | def std(x: NdarrayTensor, dim: int | tuple | None = None, unbiased: bool = False) -> NdarrayTensor: |
no outgoing calls