Skip to content

Commit

Permalink
fix error test=docs_preview
Browse files Browse the repository at this point in the history
  • Loading branch information
longranger2 committed Jul 31, 2023
1 parent 4963dac commit a496ed8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
32 changes: 19 additions & 13 deletions python/paddle/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,14 @@ def ihfft(x, n=None, axis=-1, norm="backward", name=None):
>>> spectrum = paddle.to_tensor([10.0, -5.0, 0.0, -1.0, 0.0, -5.0])
>>> print(paddle.fft.ifft(spectrum))
Tensor(shape=[6], dtype=complex64, place=Place(cpu), stop_gradient=True,
[(-0.1666666716337204+0j), (1-0j), (2.3333334922790527-0j), (3.5+0j), (2.3333334922790527+0j), (1+0j)])
[(-0.1666666716337204+0j), (1-0j),
(2.3333334922790527-0j), (3.5+0j),
(2.3333334922790527+0j), (1+0j)])
>>> print(paddle.fft.ihfft(spectrum))
Tensor(shape = [4], dtype = complex64, place = Place(cpu), stop_gradient = True,
[(-0.1666666716337204+0j), (1-0j), (2.3333334922790527-0j), (3.5+0j)])
[(-0.1666666716337204+0j), (1-0j),
(2.3333334922790527-0j), (3.5+0j)])
"""
return fft_r2c(x, n, axis, norm, forward=False, onesided=True, name=name)
Expand Down Expand Up @@ -680,13 +683,13 @@ 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=Place(cpu), stop_gradient=True,
[[[(8+0j), 0j , 0j ],
[(8+0j), 0j , 0j ],
[(8+0j), 0j , 0j ]],
[[0j , 0j , 0j ],
[0j , 0j , 0j ],
[0j , 0j , 0j ]]])
Tensor(shape=[2, 3, 4], dtype=complex64, place=Place(cpu), stop_gradient=True,
[[[(8+0j), 0j , 0j , 0j ],
[(8+0j), 0j , 0j , 0j ],
[(8+0j), 0j , 0j , 0j ]],
[[0j , 0j , 0j , 0j ],
[0j , 0j , 0j , 0j ],
[0j , 0j , 0j , 0j ]]])
"""
return fftn_r2c(x, s, axes, norm, forward=True, onesided=True, name=name)
Expand Down Expand Up @@ -849,11 +852,14 @@ def ihfftn(x, s=None, axes=None, norm="backward", name=None):
>>> spectrum = paddle.to_tensor([10.0, -5.0, 0.0, -1.0, 0.0, -5.0])
>>> print(paddle.fft.ifft(spectrum))
Tensor(shape=[6], dtype=complex64, place=Place(cpu), stop_gradient=True,
[(-0.1666666716337204+0j), (1-0j), (2.3333334922790527-0j), (3.5+0j), (2.3333334922790527+0j), (1+0j)])
[(-0.1666666716337204+0j), (1-0j),
(2.3333334922790527-0j), (3.5+0j),
(2.3333334922790527+0j), (1+0j)])
>>> print(paddle.fft.ihfft(spectrum))
Tensor(shape = [4], dtype = complex64, place = Place(cpu), stop_gradient = True,
[(-0.1666666716337204+0j), (1-0j), (2.3333334922790527-0j), (3.5+0j)])
[(-0.1666666716337204+0j), (1-0j),
(2.3333334922790527-0j), (3.5+0j)])
"""
return fftn_r2c(x, s, axes, norm, forward=False, onesided=True, name=name)

Expand Down Expand Up @@ -1032,7 +1038,7 @@ def rfft2(x, s=None, axes=(-2, -1), norm="backward", name=None):
>>> result = paddle.fft.rfft2(x)
>>> print(result.numpy())
[ 50. +0.j 0. +0.j 0. +0.j ]
[[ 50. +0.j 0. +0.j 0. +0.j ]
[-12.5+17.20477401j 0. +0.j 0. +0.j ]
[-12.5 +4.0614962j 0. +0.j 0. +0.j ]
[-12.5 -4.0614962j 0. +0.j 0. +0.j ]
Expand Down Expand Up @@ -1200,7 +1206,7 @@ def ihfft2(x, s=None, axes=(-2, -1), norm="backward", name=None):
>>> ihfft2_xp = paddle.fft.ihfft2(x)
>>> print(ihfft2_xp.numpy())
[[ 2. +0.j 0. +0.j 0. +0.j ]
[[ 2. +0.j 0. -0.j 0. -0.j ]
[-0.5-0.68819096j 0. +0.j 0. +0.j ]
[-0.5-0.16245985j 0. +0.j 0. +0.j ]
[-0.5+0.16245985j 0. +0.j 0. +0.j ]
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/metric/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,8 @@ def accuracy(input, label, k=1, correct=None, total=None, name=None):
>>> label = paddle.to_tensor([[2], [0]], dtype="int64")
>>> result = paddle.metric.accuracy(input=predictions, label=label, k=1)
>>> print(result)
0.5
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
0.50000000)
"""
if label.dtype == paddle.int32:
label = paddle.cast(label, paddle.int64)
Expand Down
1 change: 1 addition & 0 deletions python/paddle/onnx/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def export(layer, path, input_spec=None, opset_version=9, **configs):
... x_spec = paddle.static.InputSpec(shape=[None, 128], dtype='float32')
... paddle.onnx.export(model, 'linear_net', input_spec=[x_spec])
...
>>> # doctest: +SKIP('raise ImportError')
>>> export_linear_net()
>>> class Logic(paddle.nn.Layer):
Expand Down

0 comments on commit a496ed8

Please sign in to comment.