Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify sample code result #36325

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions python/paddle/tensor/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def irfft(x, n=None, axis=-1, norm="backward", name=None):
xp = paddle.to_tensor(x)
irfft_xp = paddle.fft.irfft(xp).numpy()
print(irfft_xp)
# [0. 0. 0. 4.]
# [0. 1. 0. 0.]

"""
return fft_c2r(x, n, axis, norm, forward=False, name=name)
Expand Down Expand Up @@ -477,7 +477,7 @@ def fftn(x, s=None, axes=None, norm="backward", name=None):
import numpy as np
import paddle

x = x = np.mgrid[:4, :4, :4][1]
x = np.mgrid[:4, :4, :4][1]
xp = paddle.to_tensor(x)
fftn_xp = paddle.fft.fftn(xp, axes=(1, 2)).numpy()
print(fftn_xp)
Expand Down Expand Up @@ -631,9 +631,9 @@ def rfftn(x, s=None, axes=None, norm="backward", name=None):
# use axes(2, 0)
print(paddle.fft.rfftn(x, axes=(2, 0)))
# Tensor(shape=[2, 3, 3], dtype=complex64, place=CUDAPlace(0), stop_gradient=True,
# [[[(24+0j), 0j , 0j ],
# [0j , 0j , 0j ],
# [0j , 0j , 0j ]],
# [[[(8+0j), 0j , 0j ],
# [(8+0j), 0j , 0j ],
# [(8+0j), 0j , 0j ]],
#
# [[0j , 0j , 0j ],
# [0j , 0j , 0j ],
Expand Down Expand Up @@ -1267,9 +1267,8 @@ def fftshift(x, axes=None, name=None):
import paddle

x = np.array([3, 1, 2, 2, 3], dtype=float)
scalar_temp = 0.3
n = x.size
fftfreq_xp = paddle.fft.fftfreq(n, d=scalar_temp)
fftfreq_xp = paddle.fft.fftfreq(n, d=0.3)
res = paddle.fft.fftshift(fftfreq_xp).numpy()
print(res)
# [-1.3333334 -0.6666667 0. 0.6666667 1.3333334]
Expand Down Expand Up @@ -1311,9 +1310,8 @@ def ifftshift(x, axes=None, name=None):
import paddle

x = np.array([3, 1, 2, 2, 3], dtype=float)
scalar_temp = 0.3
n = x.size
fftfreq_xp = paddle.fft.fftfreq(n, d=scalar_temp)
fftfreq_xp = paddle.fft.fftfreq(n, d=0.3)
res = paddle.fft.ifftshift(fftfreq_xp).numpy()
print(res)
# [ 1.3333334 -1.3333334 -0.6666667 0. 0.6666667]
Expand Down