MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / min

Function min

monai/transforms/utils_pytorch_numpy_unification.py:528–547  ·  view source on GitHub ↗

`torch.min` with equivalent implementation for numpy Args: x: array/tensor. Returns: the minimum of x.

(x: NdarrayTensor, dim: int | tuple | None = None, **kwargs)

Source from the content-addressed store, hash-verified

526
527
528def 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
550def std(x: NdarrayTensor, dim: int | tuple | None = None, unbiased: bool = False) -> NdarrayTensor:

Callers 15

__call__Method · 0.90
spatial_resampleFunction · 0.90
convert_points_to_boxFunction · 0.90
get_times_summaryMethod · 0.85
look_up_optionFunction · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
gaussian_combineMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_shape_generatorFunction · 0.68
test_spacingMethod · 0.68