-
Notifications
You must be signed in to change notification settings - Fork 777
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
【Hackathon 5th No.38】为 Paddle 新增 FractionalMaxPool2d / FractionalMaxPool3d API #6418
Changes from 6 commits
6e49334
5335e6b
a483b9c
1a5900c
6ad115a
1349aaf
435a38f
7b7e80c
c4e4976
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.. _cn_api_paddle_nn_FractionalMaxPool2D: | ||
|
||
|
||
FractionalMaxPool2D | ||
------------------------------- | ||
|
||
.. py:class:: paddle.nn.FractionalMaxPool2D(output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
|
||
对输入的 Tensor `x` 采取 `2` 维分数阶最大值池化操作,具体可以参考论文: | ||
|
||
[1] Ben Graham, Fractional Max-Pooling. 2015. http://arxiv.org/abs/1412.6071 | ||
|
||
其中输出的 `H` 和 `W` 由参数 `output_size` 决定。 | ||
|
||
对于各个输出维度,分数阶最大值池化的计算公式为: | ||
|
||
.. math:: | ||
|
||
\alpha &= size_{input} / size_{output} | ||
|
||
index_{start} &= ceil( \alpha * (i + u) - 1) | ||
|
||
index_{end} &= ceil( \alpha * (i + 1 + u) - 1) | ||
|
||
Output &= max(Input[index_{start}:index_{end}]) | ||
|
||
where, u \in (0, 1), i = 0,1,2...size_{output} | ||
|
||
公式中的 `u` 即为函数中的参数 `random_u`。另外,由于 `ceil` 对于正小数的操作最小值为 `1` ,因此这里需要再减去 `1` 使索引可以从 `0` 开始计数。 | ||
|
||
例如,有一个长度为 `7` 的序列 `[2, 4, 3, 1, 5, 2, 3]` , `output_size` 为 `5` , `random_u` 为 `0.3`。 | ||
则由上述公式可得 `alpha = 7/5 = 1.4` , 索引的起始序列为 `[0, 1, 3, 4, 6]` ,索引的截止序列为 `[1, 3, 4, 6, 7]` 。 | ||
进而得到论文中的随机序列为 `index_end - index_start = [1, 2, 1, 2, 1]` 。 | ||
由于池化操作的步长与核尺寸相同,同为此随机序列,最终得到池化输出为 `[2, 4, 1, 5, 3]` 。 | ||
|
||
|
||
参数 | ||
::::::::: | ||
|
||
- **output_size** (int|list|tuple):算子输出图的尺寸,其数据类型为 int 或 list,tuple。如果输出为 tuple 或者 list,则必须包含两个元素, `(H, W)` 。 `H` 和 `W` 可以是 `int` ,也可以是 `None` ,表示与输入保持一致。 | ||
- **kernel_size** (int|list|tuple, 可选) - 池化核大小。如果它是一个元组或列表,它必须包含两个整数值,(pool_size_Height, pool_size_Width)。若为一个整数,则表示 H 和 W 维度上均为该值,比如若 pool_size=2,则池化核大小为 [2,2]。默认为 `None`,表示使用 `disjoint` (`non-overlapping`) 模式。 | ||
- **random_u** (float):分数阶池化操作的浮点随机数,取值范围为 `(0, 1)` 。默认为 `None` ,由框架随机生成,可以使用 `paddle.seed` 设置随机种子。 | ||
- **return_mask** (bool,可选):如果设置为 `True` ,则会与输出一起返回最大值的索引,默认为 `False`。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 `None`。 | ||
|
||
形状 | ||
::::::::: | ||
|
||
- **x** (Tensor):默认形状为(批大小,通道数,输出特征长度,宽度),即 NCHW 格式的 4-D Tensor。其数据类型为 float16, bfloat16, float32, float64。 | ||
- **output** (Tensor):默认形状为(批大小,通道数,输出特征长度,宽度),即 NCHW 格式的 4-D Tensor。其数据类型与输入 x 相同。 | ||
|
||
返回 | ||
::::::::: | ||
|
||
计算 FractionalMaxPool2D 的可调用对象 | ||
|
||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.FractionalMaxPool2D |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. _cn_api_paddle_nn_FractionalMaxPool3D: | ||
|
||
|
||
FractionalMaxPool3D | ||
------------------------------- | ||
|
||
.. py:function:: paddle.nn.FractionalMaxPool3D(output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
|
||
对输入的 Tensor `x` 采取 `2` 维分数阶最大值池化操作,具体可以参考论文: | ||
|
||
[1] Ben Graham, Fractional Max-Pooling. 2015. http://arxiv.org/abs/1412.6071 | ||
|
||
其中输出的 `H` 和 `W` 由参数 `output_size` 决定。 | ||
|
||
对于各个输出维度,分数阶最大值池化的计算公式为: | ||
|
||
.. math:: | ||
|
||
\alpha &= size_{input} / size_{output} | ||
|
||
index_{start} &= ceil( \alpha * (i + u) - 1) | ||
|
||
index_{end} &= ceil( \alpha * (i + 1 + u) - 1) | ||
|
||
Output &= max(Input[index_{start}:index_{end}]) | ||
|
||
where, u \in (0, 1), i = 0,1,2...size_{output} | ||
|
||
公式中的 `u` 即为函数中的参数 `random_u`。另外,由于 `ceil` 对于正小数的操作最小值为 `1` ,因此这里需要再减去 `1` 使索引可以从 `0` 开始计数。 | ||
|
||
例如,有一个长度为 `7` 的序列 `[2, 4, 3, 1, 5, 2, 3]` , `output_size` 为 `5` , `random_u` 为 `0.3`。 | ||
则由上述公式可得 `alpha = 7/5 = 1.4` , 索引的起始序列为 `[0, 1, 3, 4, 6]` ,索引的截止序列为 `[1, 3, 4, 6, 7]` 。 | ||
进而得到论文中的随机序列为 `index_end - index_start = [1, 2, 1, 2, 1]` 。 | ||
由于池化操作的步长与核尺寸相同,同为此随机序列,最终得到池化输出为 `[2, 4, 1, 5, 3]` 。 | ||
|
||
|
||
参数 | ||
::::::::: | ||
|
||
- **output_size** (int|list|tuple):算子输出图的尺寸,其数据类型为 int 或 list,tuple。如果输出为 tuple 或者 list,则必须包含两个元素, `(H, W)` 。 `H` 和 `W` 可以是 `int` ,也可以是 `None` ,表示与输入保持一致。 | ||
- **kernel_size** (int|list|tuple,可选) - 池化核大小。如果它是一个元组或列表,它必须包含三个整数值,(pool_size_Depth,pool_size_Height, pool_size_Width)。若为一个整数,则表示 D,H 和 W 维度上均为该值,比如若 pool_size=2,则池化核大小为[2,2,2]。默认为 `None`,表示使用 `disjoint` (`non-overlapping`) 模式。 | ||
- **random_u** (float):分数阶池化操作的浮点随机数,取值范围为 `(0, 1)` 。默认为 `None` ,由框架随机生成,可以使用 `paddle.seed` 设置随机种子。 | ||
- **return_mask** (bool,可选):如果设置为 `True` ,则会与输出一起返回最大值的索引,默认为 `False`。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 `None`。 | ||
|
||
形状 | ||
::::::::: | ||
- **x** (Tensor):默认形状为(批大小,通道数,输出特征深度,高度,宽度),即 NCDHW 格式的 5-D Tensor。其数据类型为 float16, bfloat16, float32, float64。 | ||
- **output** (Tensor):默认形状为(批大小,通道数,输出特征深度,高度,宽度),即 NCDHW 格式的 5-D Tensor。其数据类型与输入 x 相同。 | ||
|
||
返回 | ||
::::::::: | ||
计算 FractionalMaxPool3D 的可调用对象 | ||
|
||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.FractionalMaxPool3D |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.. _cn_api_paddle_nn_functional_fractional_max_pool2d: | ||
|
||
fractional_max_pool2d | ||
------------------------------- | ||
|
||
.. py:function:: paddle.nn.functional.fractional_max_pool2d(x, output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
|
||
对输入的 Tensor `x` 采取 `2` 维分数阶最大值池化操作,具体可以参考论文: | ||
|
||
[1] Ben Graham, Fractional Max-Pooling. 2015. http://arxiv.org/abs/1412.6071 | ||
|
||
其中输出的 `H` 和 `W` 由参数 `output_size` 决定。 | ||
|
||
对于各个输出维度,分数阶最大值池化的计算公式为: | ||
|
||
.. math:: | ||
|
||
\alpha &= size_{input} / size_{output} | ||
|
||
index_{start} &= ceil( \alpha * (i + u) - 1) | ||
|
||
index_{end} &= ceil( \alpha * (i + 1 + u) - 1) | ||
|
||
Output &= max(Input[index_{start}:index_{end}]) | ||
|
||
where, u \in (0, 1), i = 0,1,2...size_{output} | ||
|
||
公式中的 `u` 即为函数中的参数 `random_u`。另外,由于 `ceil` 对于正小数的操作最小值为 `1` ,因此这里需要再减去 `1` 使索引可以从 `0` 开始计数。 | ||
|
||
例如,有一个长度为 `7` 的序列 `[2, 4, 3, 1, 5, 2, 3]` , `output_size` 为 `5` , `random_u` 为 `0.3`。 | ||
则由上述公式可得 `alpha = 7/5 = 1.4` , 索引的起始序列为 `[0, 1, 3, 4, 6]` ,索引的截止序列为 `[1, 3, 4, 6, 7]` 。 | ||
进而得到论文中的随机序列为 `index_end - index_start = [1, 2, 1, 2, 1]` 。 | ||
由于池化操作的步长与核尺寸相同,同为此随机序列,最终得到池化输出为 `[2, 4, 1, 5, 3]` 。 | ||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor):当前算子的输入,其是一个形状为 `[N, C, H, W]` 的 4-D Tensor。其中 `N` 是 batch size, `C` 是通道数, `H` 是输入特征的高度, `W` 是输入特征的宽度。其数据类型为 `float16`, `bfloat16`, `float32`, `float64` 。 | ||
- **output_size** (int|list|tuple):算子输出图的尺寸,其数据类型为 int 或 list,tuple。如果输出为 tuple 或者 list,则必须包含两个元素, `(H, W)` 。 `H` 和 `W` 可以是 `int` ,也可以是 `None` ,表示与输入保持一致。 | ||
- **kernel_size** (int|list|tuple, 可选) - 池化核大小。如果它是一个元组或列表,它必须包含两个整数值,(pool_size_Height, pool_size_Width)。若为一个整数,则表示 H 和 W 维度上均为该值,比如若 pool_size=2,则池化核大小为 [2,2]。默认为 `None`,表示使用 `disjoint` (`non-overlapping`) 模式。 | ||
- **random_u** (float):分数阶池化操作的浮点随机数,取值范围为 `(0, 1)` 。默认为 `None` ,由框架随机生成,可以使用 `paddle.seed` 设置随机种子。 | ||
- **return_mask** (bool,可选):如果设置为 `True` ,则会与输出一起返回最大值的索引,默认为 `False`。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 `None`。 | ||
|
||
返回 | ||
::::::::: | ||
`Tensor`,输入 `x` 经过分数阶最大值池化计算得到的目标 4-D Tensor,其数据类型与输入相同。 | ||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.functional.fractional_max_pool2d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.. _cn_api_paddle_nn_functional_fractional_max_pool3d: | ||
|
||
fractional_max_pool3d | ||
------------------------------- | ||
|
||
.. py:function:: paddle.nn.functional.fractional_max_pool3d(x, output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
|
||
对输入的 Tensor `x` 采取 `3` 维分数阶最大值池化操作,具体可以参考论文: | ||
|
||
[1] Ben Graham, Fractional Max-Pooling. 2015. http://arxiv.org/abs/1412.6071 | ||
|
||
其中输出的 `D`, `H` 和 `W` 由参数 `output_size` 决定。 | ||
|
||
对于各个输出维度,分数阶最大值池化的计算公式为: | ||
|
||
.. math:: | ||
|
||
\alpha &= size_{input} / size_{output} | ||
|
||
index_{start} &= ceil( \alpha * (i + u) - 1) | ||
|
||
index_{end} &= ceil( \alpha * (i + 1 + u) - 1) | ||
|
||
Output &= max(Input[index_{start}:index_{end}]) | ||
|
||
where, u \in (0, 1), i = 0,1,2...size_{output} | ||
|
||
公式中的 `u` 即为函数中的参数 `random_u`。另外,由于 `ceil` 对于正小数的操作最小值为 `1` ,因此这里需要再减去 `1` 使索引可以从 `0` 开始计数。 | ||
|
||
例如,有一个长度为 `7` 的序列 `[2, 4, 3, 1, 5, 2, 3]` , `output_size` 为 `5` , `random_u` 为 `0.3`。 | ||
则由上述公式可得 `alpha = 7/5 = 1.4` , 索引的起始序列为 `[0, 1, 3, 4, 6]` ,索引的截止序列为 `[1, 3, 4, 6, 7]` 。 | ||
进而得到论文中的随机序列为 `index_end - index_start = [1, 2, 1, 2, 1]` 。 | ||
由于池化操作的步长与核尺寸相同,同为此随机序列,最终得到池化输出为 `[2, 4, 1, 5, 3]` 。 | ||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor):当前算子的输入,其是一个形状为 `[N, C, D, H, W]` 的 5-D Tensor。其中 `N` 是 batch size, `C` 是通道数, `D` 是输入特征的深度, `H` 是输入特征的高度, `W` 是输入特征的宽度。其数据类型为 `float16`, `bfloat16`, `float32`, `float64` 。 | ||
- **output_size** (int|list|tuple):算子输出图的尺寸,其数据类型为 int 或 list,tuple。如果输出为 tuple 或者 list,则必须包含三个元素, `(D, H, W)` 。 `D`, `H` 和 `W` 可以是 `int` ,也可以是 `None` ,表示与输入保持一致。 | ||
- **kernel_size** (int|list|tuple,可选) - 池化核大小。如果它是一个元组或列表,它必须包含三个整数值,(pool_size_Depth,pool_size_Height, pool_size_Width)。若为一个整数,则表示 D,H 和 W 维度上均为该值,比如若 pool_size=2,则池化核大小为[2,2,2]。默认为 `None`,表示使用 `disjoint` (`non-overlapping`) 模式。 | ||
- **random_u** (float):分数阶池化操作的浮点随机数,取值范围为 `(0, 1)` 。默认为 `None` ,由框架随机生成,可以使用 `paddle.seed` 设置随机种子。 | ||
- **return_mask** (bool,可选):如果设置为 `True` ,则会与输出一起返回最大值的索引,默认为 `False`。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 `None`。 | ||
|
||
返回 | ||
::::::::: | ||
`Tensor`,输入 `x` 经过分数阶最大值池化计算得到的目标 5-D Tensor,其数据类型与输入相同。 | ||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.functional.fractional_max_pool3d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## [ torch 参数更多 ]torch.nn.functional.fractional_max_pool2d | ||
|
||
### [torch.nn.functional.fractional_max_pool2d](https://pytorch.org/docs/stable/generated/torch.nn.functional.fractional_max_pool2d.html#torch-nn-functional-fractional-max-pool2d) | ||
|
||
```python | ||
torch.nn.functional.fractional_max_pool2d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) | ||
``` | ||
|
||
### [paddle.nn.functional.fractional_max_pool2d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/fractional_max_pool2d_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.fractional_max_pool2d(x, output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
``` | ||
|
||
PyTorch 参数更多,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor 。仅参数名不一致。 | | ||
| kernel_size | kernel_size | 表示核大小。参数完全一致。 | | ||
| output_size | output_size | 表示目标输出尺寸。参数完全一致。 | | ||
| output_ratio | - | 表示目标输出比例。Paddle 无此参数,需要转写。 | | ||
| return_indices | return_mask | 表示是否返回最大值索引。仅参数名不一致。 | | ||
| _random_samples | random_u | 表示随机数。PyTorch 以列表形式的 Tensor 方式传入,Paddle 以 float 的方式传入,如果 PyTorch 的多个随机数相同,需要转写,如果 PyTorch 的多个随机数不同,暂无转写方式。 | | ||
|
||
### 转写示例 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 需指明是在转写哪个参数: output_ratio、_random_samples 这两个都需要转写示例 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 仅针对上文中 需要转写 的参数进行转写 |
||
|
||
#### output_ratio:目标输出比例 | ||
|
||
```python | ||
# 假设 intput 的 with=7, height=7, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是不是写个能整除的例子,更好理解点 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不好吧 ~ 因为这里本来的意图就是这种小数的方式 ~ |
||
# output_ratio = 0.75, 则目标 output 的 width = int(7*0.75) = 5, height = int(7*0.75) = 5 | ||
# Pytorch 写法 | ||
torch.nn.functional.fractional_max_pool2d(input, 2, output_ratio=[0.75, 0.75], return_indices=True) | ||
|
||
# Paddle 写法 | ||
paddle.nn.functional.fractional_max_pool2d(x, output_size=[5, 5], kernel_size=2, return_mask=True) | ||
``` | ||
|
||
#### _random_samples:随机数 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.nn.functional.fractional_max_pool2d(input, 2, output_size=[3, 3], return_indices=True, _random_samples=torch.tensor([[[0.3, 0.3]]])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 会有多个不同的_random_samples吗 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 理论上会有,但是,这个随机数是 私有 参数,应该不提倡使用 ~ |
||
|
||
# Paddle 写法 | ||
paddle.nn.functional.fractional_max_pool2d(x, output_size=[3, 3], kernel_size=2, return_mask=True, random_u=0.3) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## [ torch 参数更多 ]torch.nn.functional.fractional_max_pool3d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 问题同上 |
||
|
||
### [torch.nn.functional.fractional_max_pool3d](https://pytorch.org/docs/stable/generated/torch.nn.functional.fractional_max_pool3d.html#torch-nn-functional-fractional-max-pool3d) | ||
|
||
```python | ||
torch.nn.functional.fractional_max_pool3d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) | ||
``` | ||
|
||
### [paddle.nn.functional.fractional_max_pool3d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/fractional_max_pool3d_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.fractional_max_pool3d(x, output_size, kernel_size=None, random_u=None, return_mask=False, name=None) | ||
``` | ||
|
||
PyTorch 参数更多,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor 。仅参数名不一致。 | | ||
| kernel_size | kernel_size | 表示核大小。参数完全一致。 | | ||
| output_size | output_size | 表示目标输出尺寸。参数完全一致。 | | ||
| output_ratio | - | 表示目标输出比例。Paddle 无此参数,需要转写。 | | ||
| return_indices | return_mask | 表示是否返回最大值索引。仅参数名不一致。 | | ||
| _random_samples | random_u | 表示随机数。PyTorch 以列表形式的 Tensor 方式传入,Paddle 以 float 的方式传入,如果 PyTorch 的多个随机数相同,需要转写,如果 PyTorch 的多个随机数不同,暂无转写方式。 | | ||
|
||
### 转写示例 | ||
|
||
#### output_ratio:目标输出比例 | ||
|
||
```python | ||
# 假设 intput 的 depth=7, with=7, height=7, | ||
# output_ratio = 0.75, 则目标 output 的 depth = int(7*0.75) = 5, width = int(7*0.75) = 5, height = int(7*0.75) = 5 | ||
# Pytorch 写法 | ||
torch.nn.functional.fractional_max_pool3d(input, 2, output_ratio=[0.75, 0.75, 0.75], return_indices=True) | ||
|
||
# Paddle 写法 | ||
paddle.nn.functional.fractional_max_pool3d(x, output_size=[5, 5, 5], kernel_size=2, return_mask=True) | ||
``` | ||
|
||
#### _random_samples:随机数 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.nn.functional.fractional_max_pool3d(input, 2, output_size=[3, 3, 3], return_indices=True, _random_samples=torch.tensor([[[0.3, 0.3, 0.3]]])) | ||
|
||
# Paddle 写法 | ||
paddle.nn.functional.fractional_max_pool3d(x, output_size=[3, 3, 3], kernel_size=2, return_mask=True, random_u=0.3) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么torch的output_size是可选,我们是必选,如果torch不输入output_size,我们是怎么转写呢
所有的差异,都从torch往paddle转的角度来看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从 torch 的角度来看,output_size 与 output_ratio 必须输入一个,而 paddle 这里只使用 output_size 一个参数的原因,至少有以下几点:
参考以下 torch 的代码:
可以看到,当同时使用 output_size 与 output_ratio 时,torch 是以 output_size 为准的,但是,即便这两个参数实际上有冲突,torch 也没有提示用户存在问题 ~
由以上考虑,paddle 这里在设计时,只使用 output_size 一个参数 ~
如上面所说,如果没有 output_size,则必须有 output_ratio,不存在 output_size 与 output_ratio 同时没有的情况(torch 误导用户的地方),而 output_ratio 可以转写为 output_size ~
@zhwesky2010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@megemini 把这个点在output_size这一栏里写下吧,output_ratio属于暂无转写方式,而output_size如果不输入时,其实就对应这种暂无转写方式的情况,不然可能用户就有疑问了。
这个文档的价值就在于让不清楚两者设计背景的读者,一眼就能看懂从torch怎么转到paddle来