未验证 提交 2d228d77 编写于 作者: S SunAhong1993 提交者: GitHub

fix the api docs (#619)

* Update stargan.md

* fix the paddle_type

* add docs

* add docs

* add acknowledge

* fix the docs

* fix the docs
上级 ec638ab5
## Loss类API映射列表
该文档梳理了计算loss相关的PyTorch-PaddlePaddle API映射列表。
| 序号 | PyTorch API | PaddlePaddle API | 备注 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | [torch.nn.L1Loss](https://pytorch.org/docs/stable/generated/torch.nn.L1Loss.html?highlight=l1loss#torch.nn.L1Loss) | [paddle.nn.L1Loss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/loss/L1Loss_cn.html#l1loss) | 功能一致,PyTroch存在废弃参数`size_average``reduce`。 |
......
......@@ -91,8 +91,8 @@
| 86 | [torch.max](https://pytorch.org/docs/stable/generated/torch.max.html?highlight=max#torch.max) | [paddle.max](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/max_cn.html#max) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 87 | [torch.min](https://pytorch.org/docs/stable/generated/torch.min.html?highlight=min#torch.min) | [paddle.min](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/min_cn.html#min) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 88 | [torch.square](https://pytorch.org/docs/stable/generated/torch.square.html?highlight=square#torch.square) | [paddle.square](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/square_cn.html#square) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 89 | [torch.sub](https://pytorch.org/docs/stable/generated/torch.sub.html?highlight=sub#torch.sub) | [paddle.subtract](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/subtract_cn.html#subtract) | [差异对比](./torch.sub.md) |
| 90 | [torch.subtract](https://pytorch.org/docs/stable/generated/torch.subtract.html?highlight=subtract#torch.subtract) | [paddle.subtract](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/subtract_cn.html#subtract) | [差异对比](./torch.subtract.md) |
| 89 | [torch.sub](https://pytorch.org/docs/stable/generated/torch.sub.html?highlight=sub#torch.sub) | [paddle.subtract](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/subtract_cn.html#subtract) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.sub.md) |
| 90 | [torch.subtract](https://pytorch.org/docs/stable/generated/torch.subtract.html?highlight=subtract#torch.subtract) | [paddle.subtract](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/subtract_cn.html#subtract) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.subtract.md) |
| 91 | [torch.tanh](https://pytorch.org/docs/stable/generated/torch.tanh.html?highlight=tanh#torch.tanh) | [paddle.tanh](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/tanh_cn.html#tanh) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 92 | [torch.true_divide](https://pytorch.org/docs/stable/generated/torch.true_divide.html?highlight=true_divide#torch.true_divide) | [paddle.divide](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/divide_cn.html#divide) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 93 | [torch.dist](https://pytorch.org/docs/stable/generated/torch.dist.html?highlight=dist) | [paddle.dist](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/dist_cn.html#dist) | 功能一致,参数名不一致 |
......@@ -102,11 +102,11 @@
| 97 | [torch.norm](https://pytorch.org/docs/stable/generated/torch.norm.html?highlight=norm#torch.norm) | [paddle.norm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/norm_cn.html#norm) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor以及`dtype`参数代表输出Tensor类型 |
| 98 | [torch.prod](https://pytorch.org/docs/stable/generated/torch.prod.html?highlight=prod#torch.prod) | [paddle.prod](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/prod_cn.html#prod) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 99 | [torch.std](https://pytorch.org/docs/stable/generated/torch.std.html?highlight=std#torch.std) | [paddle.std](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/std_cn.html#std) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 100 | [torch.std_mean](https://pytorch.org/docs/stable/generated/torch.std_mean.html?highlight=std_mean#torch.std_mean) | 无对应实现 | [组合实现](./torch.std_mean.md) |
| 100 | [torch.std_mean](https://pytorch.org/docs/stable/generated/torch.std_mean.html?highlight=std_mean#torch.std_mean) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.std_mean.md) |
| 101 | [torch.sum](https://pytorch.org/docs/stable/generated/torch.sum.html?highlight=sum#torch.sum) | [paddle.sum](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/sum_cn.html#sum) | 功能一致,参数名不一致 |
| 102 | [torch.unique](https://pytorch.org/docs/stable/generated/torch.unique.html?highlight=unique#torch.unique) | [paddle.unique](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/unique_cn.html#unique) | [差异对比](./torch.unique.md) |
| 102 | [torch.unique](https://pytorch.org/docs/stable/generated/torch.unique.html?highlight=unique#torch.unique) | [paddle.unique](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/unique_cn.html#unique) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.unique.md) |
| 103 | [torch.var](https://pytorch.org/docs/stable/generated/torch.var.html?highlight=var#torch.var) | [paddle.var](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/var_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 104 | [torch.var_mean](https://pytorch.org/docs/stable/generated/torch.var_mean.html?highlight=var_mean#torch.var_mean) | 无对应实现 | [组合实现](./torch.var_mean.md) |
| 104 | [torch.var_mean](https://pytorch.org/docs/stable/generated/torch.var_mean.html?highlight=var_mean#torch.var_mean) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.var_mean.md) |
| 105 | [torch.allclose](https://pytorch.org/docs/stable/generated/torch.allclose.html?highlight=allclose#torch.allclose) | [paddle.allclose](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/allclose_cn.html) | 功能一致,参数名不一致 |
| 106 | [torch.argsort](https://pytorch.org/docs/stable/generated/torch.argsort.html?highlight=argsort#torch.argsort) | [paddle.argsort](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/argsort_cn.html) | 功能一致,参数名不一致 |
| 107 | [torch.eq](https://pytorch.org/docs/stable/generated/torch.eq.html?highlight=eq#torch.eq) | [paddle.equal](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/equal_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
......@@ -116,7 +116,7 @@
| 111 | [torch.isfinite](https://pytorch.org/docs/stable/generated/torch.isfinite.html?highlight=isfinite#torch.isfinite) | [paddle.isfinite](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/isfinite_cn.html) | 功能一致,参数名不一致 |
| 112 | [torch.isinf](https://pytorch.org/docs/stable/generated/torch.isinf.html?highlight=isinf#torch.isinf) | [paddle.isinf](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/isinf_cn.html) | 功能一致,参数名不一致 |
| 113 | [torch.isnan](https://pytorch.org/docs/stable/generated/torch.isnan.html?highlight=isnan#torch.isnan) | [paddle.isnan](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/isnan_cn.html) | 功能一致,参数名不一致 |
| 114 | [torch.kthvalue](https://pytorch.org/docs/stable/generated/torch.kthvalue.html?highlight=kthvalue#torch.kthvalue) | 无对应实现 | [组合实现](./torch.kthvalue.md) |
| 114 | [torch.kthvalue](https://pytorch.org/docs/stable/generated/torch.kthvalue.html?highlight=kthvalue#torch.kthvalue) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.kthvalue.md) |
| 115 | [torch.le](https://pytorch.org/docs/stable/generated/torch.le.html?highlight=le#torch.le) | [paddle.less_equal](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/less_equal_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 116 | [torch.lt](https://pytorch.org/docs/stable/generated/torch.lt.html?highlight=lt#torch.lt) | [paddle.less_than](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/less_than_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 117 | [torch.maximum](https://pytorch.org/docs/stable/generated/torch.maximum.html?highlight=max#torch.maximum) | [paddle.maximum](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0/api/paddle/tensor/math/maximum_cn.html#cn-api-paddle-tensor-maximum) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
......@@ -127,12 +127,12 @@
| 122 | [torch.cross](https://pytorch.org/docs/stable/generated/torch.cross.html?highlight=cross#torch.cross) | [paddle.cross](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/cross_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 123 | [torch.any](https://pytorch.org/docs/stable/generated/torch.any.html?highlight=any#torch.any) | [paddle.any](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/any_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 124 | [torch.cumsum](https://pytorch.org/docs/stable/generated/torch.cumsum.html?highlight=cumsum#torch.cumsum) | [paddle.cumsum](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/cumsum_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 125 | [torch.diag](https://pytorch.org/docs/stable/generated/torch.diag.html?highlight=diag#torch.diag) | [paddle.diag](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/diag_cn.html) | [差异对比](./torch.diag.md) |
| 125 | [torch.diag](https://pytorch.org/docs/stable/generated/torch.diag.html?highlight=diag#torch.diag) | [paddle.diag](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/diag_cn.html) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.diag.md) |
| 126 | [torch.diag_embed](https://pytorch.org/docs/stable/generated/torch.diag_embed.html?highlight=diag_embed#torch.diag_embed) | [paddle.nn.functional.diag_embed](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/diag_embed_cn.html) | 功能一致 |
| 127 | [torch.einsum](https://pytorch.org/docs/stable/generated/torch.einsum.html?highlight=einsum#torch.einsum) | paddlenlp.ops.einsum | 功能一致,需要安装[paddlenlp](https://github.com/PaddlePaddle/PaddleNLP#pip%E5%AE%89%E8%A3%85) |
| 128 | [torch.flatten](https://pytorch.org/docs/stable/generated/torch.flatten.html?highlight=flatten#torch.flatten) | [paddle.flatten](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/flatten_cn.html) | 功能一致,参数名不一致 |
| 129 | [torch.flip](https://pytorch.org/docs/stable/generated/torch.flip.html?highlight=flip#torch.flip) | [paddle.flip](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/flip_cn.html) | 功能一致,参数名不一致 |
| 130 | [torch.rot90](https://pytorch.org/docs/stable/generated/torch.rot90.html?highlight=rot90#torch.rot90) | 无对应实现 | [组合实现](./torch.rot90.md) |
| 130 | [torch.rot90](https://pytorch.org/docs/stable/generated/torch.rot90.html?highlight=rot90#torch.rot90) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.rot90.md) |
| 131 | [torch.meshgrid](https://pytorch.org/docs/stable/generated/torch.meshgrid.html?highlight=meshgrid#torch.meshgrid) | [paddle.meshgrid](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/meshgrid_cn.html) | 功能一致 |
| 132 | [torch.roll](https://pytorch.org/docs/stable/generated/torch.roll.html?highlight=roll#torch.roll) | [paddle.roll](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/roll_cn.html) | 功能一致,参数名不一致 |
| 133 | [torch.tril](https://pytorch.org/docs/stable/generated/torch.tril.html?highlight=tril#torch.tril) | [paddle.tril](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/tril_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
......@@ -141,5 +141,8 @@
| 136 | [torch.cholesky](https://pytorch.org/docs/stable/generated/torch.cholesky.html?highlight=cholesky#torch.cholesky) | [paddle.cholesky](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/cholesky_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 137 | [torch.dot](https://pytorch.org/docs/stable/generated/torch.dot.html?highlight=dot#torch.dot) | [paddle.dot](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/dot_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 138 | [torch.inverse](https://pytorch.org/docs/stable/generated/torch.inverse.html?highlight=inverse#torch.inverse) | [paddle.inverse](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/inverse_cn.html) | 功能一致,参数名不一致,PaddlePaddle未定义`out`参数代表输出Tensor |
| 139 | [torch.trace](https://pytorch.org/docs/stable/generated/torch.trace.html?highlight=trace#torch.trace) | [paddle.trace](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/trace_cn.html) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.trace.md) |
| 140 | [torch.addmv](https://pytorch.org/docs/stable/generated/torch.addmv.html?highlight=addmv#torch.addmv) | 无对应实现 | [组合实现](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/ops/torch.addmv.md) |
***持续更新...***
## torch.addmv
### [torch.addmv](https://pytorch.org/docs/stable/generated/torch.addmv.html?highlight=addmv#torch.addmv)
```python
torch.addmv(input, mat, vec, beta=1, alpha=1, out=None)
```
### 功能介绍
用于实现矩阵(`mat`)与向量(`vec`)相乘,再加上输入(`input`),PaddlePaddle目前无对应API,可使用如下代码组合实现该API。
```python
import paddle
def addmv(input, mat, vec, beta=1, alpha=1, out=None):
mv = alpha * paddle.matmul(mat, vec)
input = beta * input
out = mv + input
return out
```
\ No newline at end of file
## torch.trace
### [torch.trace](https://pytorch.org/docs/stable/generated/torch.trace.html?highlight=trace#torch.trace)
```python
torch.trace(input)
```
### [paddle.trace](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/trace_cn.html)
```python
paddle.trace(x, offset=0, axis1=0, axis2=1, name=None)
```
### 参数差异
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的Tensor。 |
| - | offset | 2D-Tensor中获取对角线的位置,默认值为0,即主对角线,PyTorch无此参数。 |
| - |axis1 | 当输入的Tensor维度大于2D时,获取对角线的二维平面的第一维,PyTorch无此参数。 |
| - | axis2 | 当输入的Tensor维度大于2D时,获取对角线的二维平面的第二维,PyTorch无此参数。 |
### 代码示例
``` python
# PyTorch示例:
import torch
x = torch.arange(1., 10.).view(3, 3)
# 输入:
# tensor([[1., 2., 3.],
# [4., 5., 6.],
# [7., 8., 9.]])
out = torch.trace(x)
# 输出:
# tensor(15.)
```
``` python
# PaddlePaddle示例:
import paddle
x = paddle.arange(1., 10.).reshape([3, 3])
# 输入:
# Tensor(shape=[3, 3], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
# [[1, 2, 3],
# [4, 5, 6],
# [7, 8, 9]])
out0 = paddle.trace(x)
# 输出out0:
# Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
# [15])
out1 = paddle.trace(x, offset=1)
# 输出out1:
# Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
# [8])
```
\ No newline at end of file
......@@ -34,7 +34,6 @@ paddle.unique(x, return_index=False, return_inverse=False, return_counts=False,
``` python
# PyTorch示例:
import torch
import torch
x = torch.tensor([[[1, 3], [2, 3]], [[1, 6], [2, 3]]], dtype=torch.float32)
output, inverse_indices, counts = torch.unique(x,
sorted=True,
......
## 工具类API映射列表
该文档梳理了与数据处理、分布式处理等相关的PyTorch-PaddlePaddle API映射列表。
| 序号 | PyTorch API | PaddlePaddle API | 备注 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | [torch.nn.DataParallel](https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html?highlight=dataparallel#torch.nn.DataParallel) | [paddle.DataParallel](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/DataParallel_cn.html#dataparallel) | [差异对比](https://github.com/PaddlePaddle/X2Paddle/tree/develop/docs/pytorch_project_convertor/API_docs/utils/torch.nn.DataParallel.md) |
......
## 视觉类API映射列表
该文档梳理了与视觉处理相关的PyTorch-PaddlePaddle API映射列表。
该文档梳理了与视觉处理相关的PyTorch-PaddlePaddle API映射列表。
| 序号 | PyTorch API | PaddlePaddle API | 备注 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------- |
| 1 | [torchvision.transforms.Compose](https://pytorch.org/vision/stable/transforms.html?highlight=compose#torchvision.transforms.Compose) | [paddle.vision.transforms.Compose](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/vision/transforms/Compose_cn.html#compose) | 功能一致 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册