-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 7th No.36】为 Paddle 代码转换工具新增 API 转换规则(第 3 组) part 1 (#6879)
* fix * fix * fix * code style * add .window. * fix * fix * fix * fix * fix * fix * fix * fix
- Loading branch information
Showing
8 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...t_from_pytorch/api_difference/audio/functional/torch.signal.windows.blackman.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.blackman | ||
### [torch.signal.windows.blackman](https://pytorch.org/docs/stable/generated/torch.signal.windows.blackman.html) | ||
|
||
```python | ||
torch.signal.windows.blackman(M, *, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `blackman`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | -| 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.blackman(5) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window('blackman', 5) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.blackman(5, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window('blackman', 5) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.blackman(5, device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window('blackman', 5) | ||
y.cpu() | ||
``` |
56 changes: 56 additions & 0 deletions
56
...ert_from_pytorch/api_difference/audio/functional/torch.signal.windows.cosine.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.cosine | ||
### [torch.signal.windows.cosine](https://pytorch.org/docs/stable/generated/torch.signal.windows.cosine.html) | ||
|
||
```python | ||
torch.signal.windows.cosine(M, *, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `cosine`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | -| 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.cosine(5) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window('cosine', 5) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.cosine(5, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window('cosine', 5) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.cosine(5, device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window('cosine', 5) | ||
y.cpu() | ||
``` |
58 changes: 58 additions & 0 deletions
58
...rom_pytorch/api_difference/audio/functional/torch.signal.windows.exponential.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.exponential | ||
### [torch.signal.windows.exponential](https://pytorch.org/docs/stable/generated/torch.signal.windows.exponential.html) | ||
|
||
```python | ||
torch.signal.windows.exponential(M, *, center=None, tau=1.0, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `exponential`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| center | - | 窗口的中心位置,Paddle 无此参数,暂无转写方式。 | | ||
| tau | - | 窗口的半衰期,Paddle 无此参数,暂无转写方式。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | - | 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.exponential(10) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window('exponential', 10) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.exponential(10, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window('exponential', 10) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.exponential(10, device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window('exponential', 10) | ||
y.cpu() | ||
``` |
66 changes: 66 additions & 0 deletions
66
...t_from_pytorch/api_difference/audio/functional/torch.signal.windows.gaussian.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.gaussian | ||
### [torch.signal.windows.gaussian](https://pytorch.org/docs/stable/generated/torch.signal.windows.gaussian.html) | ||
|
||
```python | ||
torch.signal.windows.gaussian(M, *, std=1.0, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `gaussian`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| std | - | 高斯的标准差,Pytorch 默认值为 1.0, Paddle 无此参数,需要转写。 | | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | -| 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.gaussian(10) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('gaussian', 1.0), 10) | ||
``` | ||
|
||
#### std:高斯的标准差 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.gaussian(10, std=2.0) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('gaussian', 2.0), 10) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.gaussian(10, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window(('gaussian', 1.0), 10) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.gaussian(10, device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window(('gaussian', 1.0), 10) | ||
y.cpu() | ||
``` |
66 changes: 66 additions & 0 deletions
66
..._pytorch/api_difference/audio/functional/torch.signal.windows.general_cosine.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.general_cosine | ||
### [torch.signal.windows.general_cosine](https://pytorch.org/docs/stable/generated/torch.signal.windows.general_cosine.html) | ||
|
||
```python | ||
torch.signal.windows.general_cosine(M, *, a, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `general_cosine`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| a | - | 与每个余弦函数相关的系数。Paddle 无此参数,需要转写。| | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | - | 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31]) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('general_cosine', [0.46, 0.23, 0.31]), 10) | ||
``` | ||
|
||
#### a:余弦函数相关的系数 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_cosine(10, a=[0.1, 0.2, 0.3]) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('general_cosine', [0.1, 0.2, 0.3]), 10) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31], requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window(('general_cosine', [0.46, 0.23, 0.31]), 10) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31], device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window(('general_cosine', [0.46, 0.23, 0.31]), 10) | ||
y.cpu() | ||
``` |
66 changes: 66 additions & 0 deletions
66
...pytorch/api_difference/audio/functional/torch.signal.windows.general_hamming.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
## [ torch 参数更多 ]torch.signal.windows.general_hamming | ||
### [torch.signal.windows.general_hamming](https://pytorch.org/docs/stable/generated/torch.signal.windows.general_hamming.html) | ||
|
||
```python | ||
torch.signal.windows.general_hamming(M, *, alpha=0.54, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False) | ||
``` | ||
|
||
### [paddle.audio.functional.get_window](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/audio/functional/get_window_cn.html#get-window) | ||
|
||
```python | ||
paddle.audio.functional.get_window(window, win_length, fftbins=True, dtype='float64') | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `general_hamming`。 | | ||
| M | win_length | 输入窗口的长度,也是采样点数,仅参数名不一致。 | | ||
| alpha | - | 窗口系数,Pytorch 默认值为 0.54, Paddle 无默认值,需要转写。| | ||
| sym | fftbins | 判断是否返回适用于过滤器设计的对称窗口,仅参数名不一致。 | | ||
| dtype | dtype | 返回 Tensor 的数据类型。 | | ||
| layout | - | 表示布局方式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| device | - | 表示 Tensor 存放设备位置,Paddle 无此参数,需要转写。 | | ||
| requires_grad | - | 表示是否计算梯度, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### window:窗函数类型 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_hamming(10) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('general_hamming', 0.54), 10) | ||
``` | ||
|
||
#### alpha:窗口系数 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_hamming(10, alpha = 0.6) | ||
|
||
# Paddle 写法 | ||
paddle.audio.functional.get_window(('general_hamming', 0.6), 10) | ||
``` | ||
|
||
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_hamming(10, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.audio.functional.get_window(('general_hamming', 0.54), 10) | ||
x.stop_gradient = False | ||
``` | ||
|
||
#### device: Tensor 的设备 | ||
```python | ||
# PyTorch 写法 | ||
torch.signal.windows.general_hamming(10, device=torch.device('cpu')) | ||
|
||
# Paddle 写法 | ||
y = paddle.audio.functional.get_window(('general_hamming', 0.54), 10) | ||
y.cpu() | ||
``` |
Oops, something went wrong.