带幅度和相位的Pytorch逆FFT(ifft)

jxct1oxe  于 2022-11-23  发布在  其他
关注(0)|答案(1)|浏览(251)

为了使用振幅和相位,我使用下面的函数来提取:

def calculate_fft(x):
    fft_im = torch.fft.fft(x.clone())  # bx3xhxw
    fft_amp = fft_im.real**2 + fft_im.imag**2
    fft_amp = torch.sqrt(fft_amp)
    fft_pha = torch.atan2(fft_im.imag, fft_im.real)
    return fft_amp, fft_pha

修改amppha后,如何使用它们执行逆FFT?

y = fft_amp * torch.sin(fft_pha)

英译汉这不起作用。我数学不好。

5w9g7ksd

5w9g7ksd1#

def inverse_fft(fft_amp, fft_pha):
    imag = fft_amp * torch.sin(fft_pha)
    real = fft_amp * torch.cos(fft_pha)
    fft_y = torch.complex(real, imag)
    y = torch.fft.ifft(fft_y)
    return y

这可能行得通。

相关问题