当前位置:网站首页>torch. fft
torch. fft
2022-06-26 08:45:00 【will be that man】
This is the package of discrete Fourier transform and its related functions . Before use, you must import torch.fft.
torch.fft.fft(input, n=None, dim=-1, norm=None) → Tensor
One dimensional Fourier transform .
Parameters :
- input (Tensor): Input tensor
- n (int, optional) : Signal length , If a given , Then the input tensor is either zero-padding To signal length , Or it is clipped to the signal length .
- dim (int, optional): Do the dimension of one-dimensional Fourier transform .
- norm (str, optional): Normalization mode .
- “forward” - normalize by 1/n
- “backward” - no normalization
- “ortho” - normalize by 1/sqrt(n) (making the FFT orthonormal)
Example :
>>> import torch.fft
>>> t = torch.arange(4)
>>> t
tensor([0, 1, 2, 3])
>>> torch.fft.fft(t)
tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
>>> t = tensor([0.+1.j, 2.+3.j, 4.+5.j, 6.+7.j])
>>> torch.fft.fft(t)
tensor([12.+16.j, -8.+0.j, -4.-4.j, 0.-8.j])
torch.fft.ifft(input, n=None, dim=-1, norm=None) → Tensor
One dimensional inverse Fourier transform .
Parameters : Consistent with one-dimensional Fourier transform .
Example :
>>> import torch.fft
>>> t = torch.tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
>>> torch.fft.ifft(t)
tensor([0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j])
torch.fft.fftn(input, s=None, dim=None, norm=None) → Tensor
N Dimensional Fourier transform .
Parameters :
- input (Tensor): Input tensor
- s (Tuple[int], optional): Signal size , If a given , Then the dimension to be transformed by the input tensor is either zero-padding To signal size , Or cut to signal size .
- dim (Tuple[int], optional): do N Dimension of the dimensional Fourier transform .
- norm (str, optional): Normalization mode .
- “forward” - normalize by 1/n
- “backward” - no normalization
- “ortho” - normalize by 1/sqrt(n) (making the FFT orthonormal).
n = prod(s), yes s The product of all elements in .
Example :
>>> import torch.fft
>>> x = torch.rand(10, 10, dtype=torch.complex64)
>>> fftn = torch.fft.fftn(t)
Because the discrete Fourier transform is separable , Therefore, the two-dimensional discrete Fourier transform is equivalent to two one-dimensional discrete Fourier transforms .
>>> two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
>>> torch.allclose(fftn, two_ffts)
torch.fft.ifftn(input, s=None, dim=None, norm=None) → Tensor
N Inverse dimensional Fourier transform .
Parameters : Consistent with dimensional Fourier transform .
Example :
>>> import torch.fft
>>> x = torch.rand(10, 10, dtype=torch.complex64)
>>> ifftn = torch.fft.ifftn(t)
Because inverse discrete Fourier transform is separable , Therefore, the two-dimensional inverse discrete Fourier transform is equivalent to two one-dimensional inverse discrete Fourier transforms .
>>> two_iffts = torch.fft.ifft(torch.fft.ifft(x, dim=0), dim=1)
>>> torch.allclose(ifftn, two_iffts)
torch.fft.fftshift(input, dim=None) → Tensor
Put the low frequency part of the converted frequency domain image in the middle of the image , Only for easy observation . Apply to N dimension .
Parameters :
- input (Tensor): Input frequency domain tensor .
- dim (int, Tuple[int], optional): Do the dimension of sequence exchange .
Example :
>>> f = torch.fft.fftfreq(4)
>>> f
tensor([ 0.0000, 0.2500, -0.5000, -0.2500])
>>> torch.fft.fftshift(f)
tensor([-0.5000, -0.2500, 0.0000, 0.2500])
torch.fft.ifftshift(input, dim=None) → Tensor
fftshift() The inverse transformation of .
Parameters : And fftshift Parameters are consistent .
Example :
>>> f = torch.fft.fftfreq(5)
>>> f
tensor([ 0.0000, 0.2000, 0.4000, -0.4000, -0.2000])
>>> shifted = torch.fft.fftshift(f)
>>> torch.fft.ifftshift(shifted)
tensor([ 0.0000, 0.2000, 0.4000, -0.4000, -0.2000])
边栏推荐
- xxl-job配置告警邮件通知
- 多台三菱PLC如何实现无线以太网高速通讯?
- Using transformers of hugging face to realize named entity recognition
- Object extraction_ nanyangjx
- ZLMediaKit推流拉流测试
- STM32 encountered problems using encoder module (library function version)
- FFmpeg音视频播放器实现
- Discrete device ~ resistance capacitance
- STM32 project design: an e-reader making tutorial based on stm32f4
- Interpretation of x-vlm multimodal model
猜你喜欢
随机推荐
XXL job configuration alarm email notification
Euler function: find the number of numbers less than or equal to N and coprime with n
Tokenizer description in Bert
Trimming_ nanyangjx
Apple motherboard decoding chip, lightning Apple motherboard decoding I.C
Koa_ mySQL_ Integration of TS
三菱PLC若想实现以太网无线通讯,需要具备哪些条件?
[resolved]setonnavigationitemselectedlistener() deprecated
鲸会务为活动现场提供数字化升级方案
optee中的timer代码导读
OpenCV Learning notes iii
【Unity Mirror】NetworkTeam的使用
Discrete device ~ diode triode
MPC learning notes (I): push MPC formula manually
VS2005 project call free() compiled with static libcurl library reported heap error
How to Use Instruments in Xcode
STM32 encountered problems using encoder module (library function version)
Learn signal integrity from zero (SIPI) - (1)
Opencv learning notes 3
ROS learning notes (5) -- Exploration of customized messages








