-
Notifications
You must be signed in to change notification settings - Fork 831
映射文档 No.70 #5860
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
映射文档 No.70 #5860
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5860.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
@Tomoko-hjf 麻烦review一下,感谢 |
@Tomoko-hjf 麻烦有空review一下,谢谢 |
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,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.
这里的inplace不能直接删去,可以通过 paddle.assign()赋值转写实现
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.
这里的inplace参数如果为True,则会在原地操作tensor,要想完全一致需要使用paddle.assign()赋值转写,所以需要添加转写示例
# PyTorch 写法
y = torch.nn.functional.mish(x, True)
# Paddle 写法
y = paddle.nn.functional.mish(x)
paddle.assign(y, x)
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.linalg.eig(t,out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.eig(t), y) |
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.
tuple 应该是不能通过paddle.assign()赋值,可以改为
torch.linalg.eig(t,out=(L, V))
L, V = paddle.linalg.eig(t)
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.multi_dot([[2,7], [1, 3]], out=y) |
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.
这里的输入也用 x 代替吧
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,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.
这里如果inplace=Fasle,可以写暂无转写方式,原地操作不能直接删除
torch.nanmean(x, dim=-1, dtype=torch.float32) | ||
|
||
# Paddle 写法 | ||
y = paddle.sparse.cast(x, value_dtype='float32') |
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.
这里可以通过 y.astype()实现吗,可以的话这样就能写成一行 paddle.nanmean(y.astype(),dim=-1)
已修改,其中torch.nn.functional.mishapi中核查发现参数inplace默认值为False,是之前弄错了默认值,所以此次未修改参数映射部分内容,烦请再次review |
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.
LGTM
torch.Tensor.nanmean |
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,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.
主要功能为节省显存,一般对网络训练影响不大,可直接删除。
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,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.nanmean(x, dim=-1, dtype=torch.float32) | ||
|
||
# Paddle 写法 | ||
paddle.nanmean(x.astype('float32'),dim=-1) |
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.
指定输出数据类型
对返回值astype更严谨些
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.nanmean中描述是:If specified, the input tensor is casted to [dtype] before the operation is performed. 如果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.
OK 那就应该是astype输入值
除nanmean外,均已修改 |
out=None) | ||
``` | ||
|
||
### [paddle.Tensor.nanmean](暂无对应文档) |
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.
这个文档bug,可以提issue
|
||
### 转写示例 | ||
|
||
#### inplcae |
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.
删除了就不用转写了
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.
已修改
out=None) | ||
``` | ||
|
||
### [paddle.frexp](暂无对应文档) |
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.
可以提issue报文档bug
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.
已提交issue
@zhwesky2010 请问什么时候可以合并?学院正在统计 |
完成分组No.70文档映射,新提交8个md文件。
torch.Tensor.nanmean paddle无对应api,未添加md文件
torch.frexp paddle无对应api,未添加md文件