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

Function _argmax_nd

tests/transforms/test_generate_heatmap.py:24–28  ·  view source on GitHub ↗

argmax for N-D array → returns coordinate vector (z,y,x) or (y,x).

(x)

Source from the content-addressed store, hash-verified

22
23
24def _argmax_nd(x) -> np.ndarray:
25 """argmax for N-D array → returns coordinate vector (z,y,x) or (y,x)."""
26 if isinstance(x, torch.Tensor):
27 x = x.cpu().numpy()
28 return np.asarray(np.unravel_index(np.argmax(x), x.shape))
29
30
31# Test cases for 2D array inputs with different data types

Callers 2

test_array_2dMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…