Skip to content
Open
Show file tree
Hide file tree
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
45 changes: 27 additions & 18 deletions python/paddle/audio/datasets/esc50.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,47 @@ class ESC50(AudioClassificationDataset):

Examples:

.. code-block:: python
.. code-block:: pycon

>>> # doctest: +TIMEOUT(60)
>>> import paddle
>>> import warnings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加这个干什么?这是给用户看的,加这个是跟用户说写代码时候也要 filter 掉 warning 么?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI会用root权限运行pip,pip会针对root的运行提出警告,而CI 把所有警告当错误处理,因此会导致CI错误,我没有想到更好的解决办法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

啥意思?这里哪里有执行 pip?这不是下载数据集么?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是CI自动化流程执行的pip

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这怎么还不删?

>>> import os
>>> warnings.simplefilter('ignore')
>>> os.environ['PIP_ROOT_USER_ACTION'] = 'ignore'

>>> # xdoctest: +TIMEOUT(100)
>>> mode = 'dev'
>>> esc50_dataset = paddle.audio.datasets.ESC50(mode=mode, # type: ignore[arg-type]
... feat_type='raw')
>>> esc50_dataset = paddle.audio.datasets.ESC50(
... mode=mode, # type: ignore[arg-type]
... feat_type='raw',
... )
>>> for idx in range(5):
... audio, label = esc50_dataset[idx]
... # do something with audio, label
... print(audio.shape, label)
... # [audio_data_length] , label_id
[220500] 0
[220500] 14
[220500] 36
[220500] 36
[220500] 19

>>> esc50_dataset = paddle.audio.datasets.ESC50(mode=mode, # type: ignore[arg-type]
... feat_type='mfcc',
... n_mfcc=40)
paddle.Size([220500]) 0
paddle.Size([220500]) 0
paddle.Size([220500]) 0
paddle.Size([220500]) 2
paddle.Size([220500]) 2

>>> # xdoctest: +SKIP("dataset too large for CI")
>>> esc50_dataset = paddle.audio.datasets.ESC50(
... mode=mode, # type: ignore[arg-type]
... feat_type='mfcc',
... n_mfcc=40,
... )
>>> for idx in range(5):
... audio, label = esc50_dataset[idx]
... # do something with mfcc feature, label
... print(audio.shape, label)
... # [feature_dim, length] , label_id
[40, 1723] 0
[40, 1723] 14
[40, 1723] 36
[40, 1723] 36
[40, 1723] 19
paddle.Size([40, 1723]) 0
paddle.Size([40, 1723]) 14
paddle.Size([40, 1723]) 36
paddle.Size([40, 1723]) 36
paddle.Size([40, 1723]) 19

"""

Expand Down
10 changes: 6 additions & 4 deletions python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6663,15 +6663,17 @@ def view_as_complex(input: Tensor) -> Tensor:
Tensor, The output. Data type is 'complex64' or 'complex128', sharing the same memory with input.

Examples:
.. code-block:: python
.. code-block:: pycon

>>> import paddle
>>> x = paddle.arange(12, dtype=paddle.float32).reshape([2, 3, 2])
>>> y = paddle.as_complex(x)
>>> print(y)
Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[[1j , (2+3j) , (4+5j) ],
[(6+7j) , (8+9j) , (10+11j)]])
[[(0.00000000+1.00000000j) , (2.00000000+3.00000000j) ,
(4.00000000+5.00000000j) ],
[(6.00000000+7.00000000j) , (8.00000000+9.00000000j) ,
(10.00000000+11.00000000j)]])
"""

return as_complex(x=input)
Expand Down Expand Up @@ -7744,7 +7746,7 @@ def unflatten(
Tensor, return the unflatten tensor of :attr:`x`.

Examples:
.. code-block:: python
.. code-block:: pycon

>>> import paddle

Expand Down
Loading