Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
54930b60
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
54930b60
编写于
4月 28, 2020
作者:
C
cc
提交者:
GitHub
4月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add randperm cn doc (#1998)
* Add randperm cn doc, test=develop, test=document_preview
上级
770eab5c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
1 deletion
+44
-1
doc/fluid/api_cn/tensor_cn/randperm_cn.rst
doc/fluid/api_cn/tensor_cn/randperm_cn.rst
+44
-1
未找到文件。
doc/fluid/api_cn/tensor_cn/randperm_cn.rst
浏览文件 @
54930b60
.. _cn_api_tensor_random_randperm:
randperm
-------------------------------
**版本升级,文档正在开发中**
.. py:function:: paddle.tensor.random.randperm(n, out=None, dtype="int64", device=None, stop_gradient=True, seed=0)
该OP返回一个数值在0到n-1、顺序随机的整数排列。
参数:
- **n** (int): 整数排列的上限,应该大于0。
- **out** (Variable, optional): 可选的输出变量,如果不为 `None` ,返回的整数排列保存在该变量中,默认是 `None` 。
- **dtype** (np.dtype|core.VarDesc.VarType|str, optional): 整数排列的数据类型,支持 `int64` 和 `int32` ,默认是 `int64` 。
- **device** (str, optional): 指定整数排列所在的设备内存。设置为 `cpu` 则保存在 `cpu` 内存中,设置为 `gpu` ,则保存在 `gpu` 内存中,设置为 `None` 则保存在运行的设备内存中。默认是 `None` 。
- **stop_gradient** (bool, optional): 返回的整数排列是否记录并更新梯度,默认是 `True` 。
- **seed** (int, optional): 设置随机种子。`seed` 等于0时,每次返回不同的整数排列;`seed` 不等于0时,相同的 `seed` 返回相同的整数排列。
返回: 一个数值在0到n-1、顺序随机的整数排列。
返回类型: Variable
**代码示例**:
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
# Note that, the random permutation returned by randperm depends
# the random seed in computer, so the output in the next example
# will be change.
with fluid.dygraph.guard():
out_1 = paddle.randperm(6)
print(out_1.numpy()) # Random permutation, for example [2 4 5 0 3 1]
out_2 = fluid.dygraph.to_variable(
np.array([0, 1, 2, 3])).astype(np.int64)
paddle.randperm(6, out_2)
print(out_2.numpy()) # Random permutation, for example [5 0 2 4 1 3]
out_3 = paddle.randperm(6, dtype="int32", device="cpu")
print(out_3.numpy()) # Random permutation, for example [3 1 4 2 5 0]
out_4 = paddle.randperm(6, device="cpu", stop_gradient=True)
print(out_4.numpy()) # Random permutation, for example [3 1 5 2 0 4]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录