meddlr.ops#
Meddlr provides some utilities for complex, categorical, and fft-related operations. All operations assume the first dimension is the batch dimension.
Complex Utilities#
These utilities are used to perform complex arithmetic with both complex tensors
and real views of compex tensors, where the last dimension is 2 for real/imaginary
components. Because these utilities are optimized for complex numbers, they will fail
on real-valued tensors that do not follow the real-view convention described above.
Note, because these utilites support real-view tensors, if the last dimension
is 2, it will be interpreted as a real-view of a complex tensor.
In your code, we recommend using complex tensors when handling complex numbers
to avoid ambiguity between real and complex numbers.
Computes the absolute value (magnitude) of a complex-valued input tensor (x). |
|
Computes the phase of a complex-valued input tensor (x). |
|
Apply a center crop to the input image or batch of complex images. |
|
Permute complex-valued |
|
Permute complex-valued |
|
Computes the complex conjugate of complex-valued input tensor (x). |
|
Computes real and imaginary values from polar representation. |
|
Returns a binary mask for where |
|
Gets imaginary component of complex tensor. |
|
Returns if |
|
Returns |
|
Computes complex-valued matrix product of X and Y. |
|
Multiplies two complex-valued tensors x and y. |
|
Iteratively computes first singular value of X using power method. |
|
Gets real component of complex tensor. |
|
Compute the root-sum-of-squares (RSS) for complex inputs. |
|
Computes singular value decomposition of batch of complex-valued matrices. |
|
Convert real-valued PyTorch tensor to complex-valued numpy array. |
|
Convert complex-valued numpy array to real-valued PyTorch tensor. |
Categorical Utilities#
These utilities are designed to perform categorical operations on tensors, such as converting between categorical and one-hot representations and converting from logits to probabilities.
Converts categorical predictions to one-hot encoded predictions. |
|
Converts logits to probabilities. |
|
Converts one-hot encoded predictions to categorical predictions. |
|
Converts one-hot encoded predictions or logits to category. |
Fourier Transform Utilities#
Apply centered 2 dimensional Fast Fourier Transform. |
|
Apply centered 2 dimensional Fast Fourier Transform. |
|
Apply 1D centered Fast Fourier Transform (FFT). |
|
Apply nD centered fast fourier transform. |
|
Similar to np.fft.fftshift but applies to PyTorch Tensors |
|
Apply centered 2-dimensional Inverse Fast Fourier Transform. |
|
Apply centered 2-dimensional Inverse Fast Fourier Transform. |
|
Apply centered 2 dimensional Fast Fourier Transform. |
|
Apply nD centered inverse fast fourier transform. |
|
Similar to np.fft.ifftshift but applies to PyTorch Tensors |