未验证 提交 bb7ca948 编写于 作者: W WJJ1995 提交者: GitHub

fixed bug for split (#694)

上级 cfc8c631
......@@ -28,7 +28,7 @@
| 23 | [torch.narrow](https://pytorch.org/docs/stable/generated/torch.narrow.html?highlight=narrow#torch.narrow) | [paddle.slice](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/slice_cn.html#slice) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.narrow.md) |
| 24 | [torch.nonzero](https://pytorch.org/docs/stable/generated/torch.nonzero.html?highlight=nonzero#torch.nonzero) | [paddle.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nonzero_cn.html#nonzero) | 功能一致,参数名不一致 |
| 25 | [torch.reshape](https://pytorch.org/docs/stable/generated/torch.reshape.html?highlight=reshape#torch.reshape) | [paddle.reshape](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/reshape_cn.html#reshape) | 功能一致,参数名不一致 |
| 26 | [torch.split](https://pytorch.org/docs/stable/generated/torch.split.html?highlight=split#torch.split) | [paddle.split](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/split_cn.html#split) | 功能一致,参数名不一致 |
| 26 | [torch.split](https://pytorch.org/docs/stable/generated/torch.split.html?highlight=split#torch.split) | [paddle.split](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/split_cn.html#split) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.split.md) |
| 27 | [torch.squeeze](https://pytorch.org/docs/stable/generated/torch.squeeze.html?highlight=squeeze#torch.squeeze) | [paddle.squeeze](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/squeeze_cn.html#squeeze) | 功能一致,参数名不一致 |
| 28 | [torch.stack](https://pytorch.org/docs/stable/generated/torch.stack.html?highlight=stack#torch.stack) | [paddle.stack](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/stack_cn.html#stack) | 功能一致,参数名不一致 |
| 29 | [torch.t](https://pytorch.org/docs/stable/generated/torch.t.html) | [paddle.t](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/t_cn.html#t) | 功能一致,参数名不一致 |
......
## torch.split
### [torch.split](https://pytorch.org/docs/stable/generated/torch.split.html?highlight=torch%20split#torch.split)
```python
torch.split(tensor,
split_size_or_sections,
dim=0)
```
### [paddle.split](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/split_cn.html#split)
```python
paddle.split(x,
num_or_sections,
axis=0,
name=None)
```
### 参数差异
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensor | x | 表示输入Tensor。 |
| split_size_or_sections | num_or_sections | 当类型为int时,torch表示单个块大小,paddle表示结果有多少个块 |
| dim | axis | 表示需要分割的维度。 |
### 功能差异
#### 使用方式
***PyTorch***:第二个参数split_size_or_sections类型为int或者list(int)。
***PaddlePaddle***:第二个参数num_or_sections类型为int、list(int)或者tuple(int)。
### 代码示例
``` python
# PyTorch示例:
a = torch.arange(10).reshape(5,2)
# 输出
# tensor([[0, 1],
# [2, 3],
# [4, 5],
# [6, 7],
# [8, 9]])
torch.split(a, 2, 1)
# 输出
# (tensor([[0, 1],
# [2, 3],
# [4, 5],
# [6, 7],
# [8, 9]]),)
```
``` python
# PaddlePaddle示例:
b = paddle.arange(10).reshape([5,2])
# 输出
# Tensor(shape=[5, 2], dtype=int64, place=CPUPlace, stop_gradient=True,
# [[0, 1],
# [2, 3],
# [4, 5],
# [6, 7],
# [8, 9]])
paddle.split(b, 2, 1)
# 输出
# [Tensor(shape=[5, 1], dtype=int64, place=CPUPlace, stop_gradient=True,
# [[0],
# [2],
# [4],
# [6],
# [8]]), Tensor(shape=[5, 1], dtype=int64, place=CPUPlace, stop_gradient=True,
# [[1],
# [3],
# [5],
# [7],
# [9]])]
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册