- paddle.fft. fft2 ( x, s=None, axes=(- 2, - 1), norm='backward', name=None )
Compute the 2-D discrete Fourier Transform
This function computes the N-D discrete Fourier Transform over any axes in an M-D array by means of the Fast Fourier Transform (FFT). By default, the transform is computed over the last two axes of the input array, i.e., a 2-dimensional FFT.
x (Tensor) – The input data. It’s a Tensor type.
s (sequence of ints, optional) – Shape (length of each transformed axis) of the output. It should be a sequence of 2 integers. This corresponds to
fft(x, n). Along each axis, if the given shape is smaller than that of the input, the input is cropped. If it is larger, the input is padded with zeros. if s is not given, the shape of the input along the axes specified by axes is used. Default is None.
axes (sequence of ints, optional) – Axes over which to compute the FFT. It should be a sequence of 2 integers. If not specified, the last two axes are used by default.
norm (str, optional) – Indicates which direction to scale the forward or backward transform pair and what normalization factor to use. The parameter value must be one of “forward” or “backward” or “ortho”. Default is “backward”.
name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.
Complex tensor. The truncated or zero-padded input, transformed along the axes indicated by axes, or the last two axes if axes is not given.
import numpy as np import paddle x = np.mgrid[:2, :2] xp = paddle.to_tensor(x) fft2_xp = paddle.fft.fft2(xp).numpy() print(fft2_xp) # [[ 2.+0.j -2.+0.j] # [ 0.+0.j 0.+0.j]]