Skip to content

映射文档 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

Merged
merged 6 commits into from
May 25, 2023
Merged

映射文档 No.70 #5860

merged 6 commits into from
May 25, 2023

Conversation

Hzwords
Copy link
Contributor

@Hzwords Hzwords commented May 6, 2023

完成分组No.70文档映射,新提交8个md文件。
torch.Tensor.nanmean paddle无对应api,未添加md文件
torch.frexp paddle无对应api,未添加md文件

@paddle-bot
Copy link

paddle-bot bot commented May 6, 2023

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5860.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

@Hzwords
Copy link
Contributor Author

Hzwords commented May 6, 2023

@Tomoko-hjf 麻烦review一下,感谢

@Hzwords
Copy link
Contributor Author

Hzwords commented May 9, 2023

@Tomoko-hjf 麻烦有空review一下,谢谢

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的 Tensor ,仅参数名不一致。 |
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的inplace不能直接删去,可以通过 paddle.assign()赋值转写实现

Copy link
Collaborator

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)

Copy link
Contributor Author

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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 无此参数,一般对网络训练结果影响不大,可直接删除。 |
Copy link
Collaborator

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')
Copy link
Collaborator

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)

@Hzwords
Copy link
Contributor Author

Hzwords commented May 11, 2023

已修改,其中torch.nn.functional.mishapi中核查发现参数inplace默认值为False,是之前弄错了默认值,所以此次未修改参数映射部分内容,烦请再次review

Copy link
Collaborator

@Fancy-hjyp Fancy-hjyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhwesky2010
Copy link
Collaborator

torch.Tensor.nanmean
torch.frexp
这两个都有对应的API,如果在API文档里搜不到,可以直接import paddle跑下试试
API中文文档缺失可以提issue报bug

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的 Tensor ,仅参数名不一致。 |
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,需要进行转写。 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要功能为节省显存,一般对网络训练影响不大,可直接删除。

### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,暂无转写方式。 |
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

指定输出数据类型
对返回值astype更严谨些

Copy link
Contributor Author

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那里在执行操作后才转换类型,会不会有影响操作结果的可能?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK 那就应该是astype输入值

@Hzwords
Copy link
Contributor Author

Hzwords commented May 16, 2023

除nanmean外,均已修改

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label May 17, 2023
out=None)
```

### [paddle.Tensor.nanmean](暂无对应文档)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文档bug,可以提issue


### 转写示例

#### inplcae
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除了就不用转写了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

out=None)
```

### [paddle.frexp](暂无对应文档)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以提issue报文档bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已提交issue

@Hzwords
Copy link
Contributor Author

Hzwords commented May 24, 2023

@zhwesky2010 请问什么时候可以合并?学院正在统计

@zhwesky2010 zhwesky2010 merged commit a1f634d into PaddlePaddle:develop May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants