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

Function complex_abs_t

monai/apps/reconstruction/complex_utils.py:102–114  ·  view source on GitHub ↗

Compute the absolute value of a complex tensor. Args: x: Input tensor with 2 channels in the last dimension representing real and imaginary parts. Returns: Absolute value along the last dimension

(x: Tensor)

Source from the content-addressed store, hash-verified

100
101
102def complex_abs_t(x: Tensor) -> Tensor:
103 """
104 Compute the absolute value of a complex tensor.
105
106 Args:
107 x: Input tensor with 2 channels in the last dimension representing real and imaginary parts.
108
109 Returns:
110 Absolute value along the last dimension
111 """
112 if x.shape[-1] != 2:
113 raise ValueError(f"x.shape[-1] is not 2 ({x.shape[-1]}).")
114 return (x[..., 0] ** 2 + x[..., 1] ** 2) ** 0.5 # type: ignore
115
116
117def complex_abs(x: NdarrayOrTensor) -> NdarrayOrTensor:

Callers 2

forwardMethod · 0.90
complex_absFunction · 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…