Skip to content
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.240 #5951

Merged
merged 5 commits into from
Jul 5, 2023
Merged

映射文档 No.240 #5951

merged 5 commits into from
Jul 5, 2023

Conversation

txyugood
Copy link
Contributor

PaddlePaddle/PaConvert#112
torch版本的lengths参数支持比例方式划分,paddle版本的不支持故修改为参数不一致。

@paddle-bot
Copy link

paddle-bot bot commented Jun 21, 2023

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

lengths = [0.3, 0.3, 0.4]
lengths = [length * datasets.__len__() for length in lengths]
datasets = paddle.io.random_split(dataset,
lengths,
Copy link
Contributor

Choose a reason for hiding this comment

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

range(30)和dataset转化参数名不一致,容易引起误解,generator也要保持一致

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

| generator | generator | 指定采样 data_source 的采样器。默认值为 None。 |

### 转写示例
当参数 lenghts 为总长度的比例数组时,转写如下:
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.

Done.

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ |---------------------------------------------------------------------|
| dataset | dataset | 表示可迭代数据集。 |
| lengths | lengths | PyTorch:总和为原数组长度或 1.0,子集合长度或总长度比例数组。PaddlePaddle: 总和为原数组长度的,子集合长度数组。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

感觉原来的API文档写的不太直白:
可为子集合长度列表,列表总和为原数组长度。也可为子集合所占比例列表,列表总和为1.0
子集合长度列表,列表总和为原数组长度。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


# Paddle 写法
lengths = [0.3, 0.3, 0.4]
lengths = [length * dataset.__len__() for length in lengths]
Copy link
Collaborator

Choose a reason for hiding this comment

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

len(dataset) * i for i in lengths

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

lengths = [length * dataset.__len__() for length in lengths]
datasets = paddle.io.random_split(dataset,
lengths,
generator=paddle.fluid.core.default_cpu_generator().manual_seed(0))
Copy link
Collaborator

Choose a reason for hiding this comment

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

可写简单点:generator=paddle.seed(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

lengths = [0.3, 0.3, 0.4]
datasets = torch.utils.data.random_split(dataset,
lengths,
generator=torch.Generator().manual_seed(0))
Copy link
Collaborator

Choose a reason for hiding this comment

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

可写简单点:torch.manual_seed(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

| generator | generator | 指定采样 data_source 的采样器。默认值为 None。 |

### 转写示例
lenghts: 子集合长度列表
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.

Done.

@zhwesky2010 zhwesky2010 merged commit c6e9c7e into PaddlePaddle:develop Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants