当前位置:网站首页>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])
边栏推荐
- Detailed process of generating URDF file from SW model
- Zlib static library compilation
- The principle and function of focus
- VS2005 project call free() compiled with static libcurl library reported heap error
- Text to SQL model ----irnet
- What are the conditions for Mitsubishi PLC to realize Ethernet wireless communication?
- Compiling owncloud client on win10
- Why are you impetuous
- Koa_ mySQL_ Integration of TS
- Implementation of ffmpeg audio and video player
猜你喜欢

Recognize the interruption of 80s51

Koa_ mySQL_ Integration of TS

Digital image processing learning (II): Gaussian low pass filter

Relationship extraction --r-bert

Can the encrypted JS code and variable name be cracked and restored?

Introduction of laser drive circuit

Object extraction_ nanyangjx

WBC learning notes (I): manually push WBC formula

Bezier curve learning

First character that appears only once
随机推荐
Summary of common instructions for arm assembly
Undefined symbols for architecture i386 is related to third-party compiled static libraries
Addition of attention function in yolov5
Batch execute SQL file
Relationship extraction -- casrel
Record the problem yaml file contains Chinese message 'GBK' error
Formula understanding in quadruped control
Esp8266wifi module tutorial: punctual atom atk-esp8266 for network communication, single chip microcomputer and computer, single chip microcomputer and mobile phone to send data
Koa_ mySQL_ Integration of TS
KNN resolution
Whale conference provides digital upgrade scheme for the event site
Time functions supported in optee
Deploy wiki system Wiki in kubesphere JS and enable Chinese full-text retrieval
Using MySQL and Qt5 to develop takeout management system (I): environment configuration
Use a switch to control the lighting and extinguishing of LEP lamp
Stanford doggo source code study
Remote centralized control of distributed sensor signals using wireless technology
How to correctly PIP install pyscipopt
Matlab function foundation (directly abandon version)
Using transformers of hugging face to realize named entity recognition