torchcvnn.transforms

Conversion transforms

Unsqueeze(dim)

Add a singleton dimension to the input array/tensor.

ToTensor(dtype)

Converts numpy array or torch tensor to torch tensor of specified dtype.

RealImaginary([dtype])

Transform a complex-valued tensor into its real and imaginary components.

ToImaginary()

Extracts the imaginary part of a complex-valued input tensor.

ToReal()

Extracts the real part of a complex-valued input tensor.

RandomPhase(dtype[, centering])

Randomly phase-shifts complex-valued input data. This transform applies a random phase shift to complex-valued input tensors/arrays by multiplying the input with exp(j*phi), where phi is uniformly distributed in [0, 2π] or [-π, π] if centering is enabled. :param dtype: str Data type for the output. Must be one of the supported complex dtypes. :param centering: bool, optional. If True, centers the random phase distribution around 0 by subtracting π from the generated phases. Default is False.

Normalize(means, covs[, eps])

Per-channel 2x2 normalization of [Re, Im]. This transform normalizes complex-valued input data by centering and scaling it. It supports both numpy arrays and PyTorch tensors as input. :param means: Per-channel means for centering. Shape (C, 2) where C is number of channels. :type means: array-like :param covs: Per-channel 2x2 covariance matrices for scaling. Shape (C, 2, 2). Covariance matrices must be symmetric positive definite. :type covs: array-like.

Complex transforms

LogAmplitude([min_value, max_value, keep_phase])

This transform applies a logarithmic scaling to the amplitude/magnitude of complex values while optionally preserving the phase information.

Amplitude(dtype)

Transform a complex-valued tensor into its amplitude/magnitude.

RandomPhase(dtype[, centering])

Randomly phase-shifts complex-valued input data. This transform applies a random phase shift to complex-valued input tensors/arrays by multiplying the input with exp(j*phi), where phi is uniformly distributed in [0, 2π] or [-π, π] if centering is enabled. :param dtype: str Data type for the output. Must be one of the supported complex dtypes. :param centering: bool, optional. If True, centers the random phase distribution around 0 by subtracting π from the generated phases. Default is False.

Resize transforms

SpatialResize(size)

Resize a complex tensor to a given size.

FFTResize(size[, axis, scale, dtype])

Resizes an input image in spectral domain with Fourier Transformations.

CenterCrop(height, width)

Center crops an input array/tensor to the specified size.

PadIfNeeded(min_height, min_width[, ...])

Pad an image if its dimensions are smaller than specified minimum dimensions.

Fourier transforms

FFT2([axis])

Applies 2D Fast Fourier Transform (FFT) to the input.

IFFT2([axis])

Applies 2D inverse Fast Fourier Transform (IFFT) to the input.