-
Notifications
You must be signed in to change notification settings - Fork 724
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
映射文档 No.240 #5951
Conversation
感谢你贡献飞桨文档,文档预览构建中,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, |
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.
range(30)和dataset转化参数名不一致,容易引起误解,generator也要保持一致
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.
Done.
| generator | generator | 指定采样 data_source 的采样器。默认值为 None。 | | ||
|
||
### 转写示例 | ||
当参数 lenghts 为总长度的比例数组时,转写如下: |
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.
Done.
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ |---------------------------------------------------------------------| | ||
| dataset | dataset | 表示可迭代数据集。 | | ||
| lengths | lengths | PyTorch:总和为原数组长度或 1.0,子集合长度或总长度比例数组。PaddlePaddle: 总和为原数组长度的,子集合长度数组。 | |
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.
感觉原来的API文档写的不太直白:
可为子集合长度列表,列表总和为原数组长度。也可为子集合所占比例列表,列表总和为1.0
子集合长度列表,列表总和为原数组长度。
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.
Done.
|
||
# Paddle 写法 | ||
lengths = [0.3, 0.3, 0.4] | ||
lengths = [length * dataset.__len__() for length in lengths] |
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.
len(dataset) * i for i in lengths
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.
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)) |
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.
可写简单点:generator=paddle.seed(0)
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.
Done.
lengths = [0.3, 0.3, 0.4] | ||
datasets = torch.utils.data.random_split(dataset, | ||
lengths, | ||
generator=torch.Generator().manual_seed(0)) |
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.manual_seed(0)
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.
Done.
| generator | generator | 指定采样 data_source 的采样器。默认值为 None。 | | ||
|
||
### 转写示例 | ||
lenghts: 子集合长度列表 |
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.
Done.
PaddlePaddle/PaConvert#112
torch版本的lengths参数支持比例方式划分,paddle版本的不支持故修改为参数不一致。