torch / torch
torch.rfft¶
-
torch.
rfft
(input, signal_ndim, normalized=False, onesided=True) → Tensor¶ Real-to-complex Discrete Fourier Transform.
Warning
The function
torch.rfft()
is deprecated and will be removed in a future PyTorch release. Use the new torch.fft module functions, instead, by importing torch.fft and callingtorch.fft.rfft()
for one-sided output, ortorch.fft.fft()
for two-sided output.This method computes the real-to-complex discrete Fourier transform. It is mathematically equivalent with
fft()
with differences only in formats of the input and output.This method supports 1D, 2D and 3D real-to-complex transforms, indicated by
signal_ndim
.input
must be a tensor with at leastsignal_ndim
dimensions with optionally arbitrary number of leading batch dimensions. Ifnormalized
is set toTrue
, this normalizes the result by dividing it with so that the operator is unitary, where is the size of signal dimension .The real-to-complex Fourier transform results follow conjugate symmetry:
where the index arithmetic is computed modulus the size of the corresponding dimension, is the conjugate operator, and =
signal_ndim
.onesided
flag controls whether to avoid redundancy in the output results. If set toTrue
(default), the output will not be full complex result of shape , where is the shape ofinput
, but instead the last dimension will be halfed as of size .The inverse of this function is
irfft()
.Note
For CUDA tensors, an LRU cache is used for cuFFT plans to speed up repeatedly running FFT methods on tensors of same geometry with same configuration. See cuFFT plan cache for more details on how to monitor and control the cache.
Warning
Due to limited dynamic range of half datatype, performing this operation in half precision may cause the first element of result to overflow for certain inputs.
Warning
For CPU tensors, this method is currently only available with MKL. Use
torch.backends.mkl.is_available()
to check if MKL is installed.- Parameters
input (Tensor) – the input tensor of at least
signal_ndim
dimensionssignal_ndim (int) – the number of dimensions in each signal.
signal_ndim
can only be 1, 2 or 3normalized (bool, optional) – controls whether to return normalized results. Default:
False
onesided (bool, optional) – controls whether to return half of results to avoid redundancy. Default:
True
- Returns
A tensor containing the real-to-complex Fourier transform result
- Return type
Example:
>>> x = torch.randn(5, 5) >>> torch.rfft(x, 2).shape torch.Size([5, 3, 2]) >>> torch.rfft(x, 2, onesided=False).shape torch.Size([5, 5, 2])
此页内容是否对您有帮助