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)
| 100 | |
| 101 | |
| 102 | def 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 | |
| 117 | def complex_abs(x: NdarrayOrTensor) -> NdarrayOrTensor: |
no outgoing calls
no test coverage detected
searching dependent graphs…