Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
e613a9bc
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
5
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看板
未验证
提交
e613a9bc
编写于
9月 08, 2020
作者:
C
Chen Long
提交者:
GitHub
9月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some docs test=develop (#2564)
上级
7be8cf9c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
112 addition
and
114 deletion
+112
-114
doc/paddle/api/paddle/fluid/layers/fill_constant_cn.rst
doc/paddle/api/paddle/fluid/layers/fill_constant_cn.rst
+0
-4
doc/paddle/api/paddle/fluid/layers/ones_cn.rst
doc/paddle/api/paddle/fluid/layers/ones_cn.rst
+0
-4
doc/paddle/api/paddle/fluid/layers/zeros_cn.rst
doc/paddle/api/paddle/fluid/layers/zeros_cn.rst
+0
-4
doc/paddle/api/paddle/tensor/random/normal_cn.rst
doc/paddle/api/paddle/tensor/random/normal_cn.rst
+5
-5
doc/paddle/api/paddle/tensor/random/rand_cn.rst
doc/paddle/api/paddle/tensor/random/rand_cn.rst
+17
-27
doc/paddle/api/paddle/tensor/random/randint_cn.rst
doc/paddle/api/paddle/tensor/random/randint_cn.rst
+17
-29
doc/paddle/api/paddle/tensor/random/randn_cn.rst
doc/paddle/api/paddle/tensor/random/randn_cn.rst
+17
-27
doc/paddle/api/paddle/tensor/random/randperm_cn.rst
doc/paddle/api/paddle/tensor/random/randperm_cn.rst
+6
-14
doc/paddle/api/paddle/tensor/random/standard_normal_cn.rst
doc/paddle/api/paddle/tensor/random/standard_normal_cn.rst
+50
-0
未找到文件。
doc/paddle/api/paddle/fluid/layers/fill_constant_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -27,10 +27,6 @@ fill_constant
返回类型:变量(Variable)
抛出异常:
- :code:`TypeError`: dtype必须是bool,float16,float32,float64,int32和int64之一,输出Tensor的数据类型必须与dtype相同。
- :code:`TypeError`: 当 `shape` 的数据类型不是list、tuple、Variable。
**代码示例**:
.. code-block:: python
...
...
doc/paddle/api/paddle/fluid/layers/ones_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -14,10 +14,6 @@ ones
返回:值全为1的Tensor,数据类型和 ``dtype`` 定义的类型一致。
抛出异常:
- ``TypeError`` - 当 ``dtype`` 不是bool、 float16、float32、float64、int32、int64和None时。
- ``TypeError`` - 当 ``shape`` 不是tuple、list、或者Tensor时, 当 ``shape`` 为Tensor,其数据类型不是int32或者int64时。
**代码示例**:
.. code-block:: python
...
...
doc/paddle/api/paddle/fluid/layers/zeros_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -14,10 +14,6 @@ zeros
返回:值全为0的Tensor,数据类型和 ``dtype`` 定义的类型一致。
抛出异常:
- ``TypeError`` - 当 ``dtype`` 不是bool、 float16、float32、float64、int32、int64。
- ``TypeError`` - 当 ``shape`` 不是tuple、list、或者Tensor时。 当 ``shape`` 为Tensor,其数据类型不是int32或者int64时。
**代码示例**:
.. code-block:: python
...
...
doc/paddle/api/paddle/tensor/random/normal_cn.rst
浏览文件 @
e613a9bc
.. _cn_api_tensor_normal:
.. _cn_api_tensor_
random_
normal:
normal
-------------------------------
...
...
@@ -36,13 +36,13 @@ normal
paddle.disable_static()
out1 = paddle.normal(shape=[2, 3])
# [[ 0.17501129 0.32364586 1.561118 ]
# [-1.7232178 1.1545963 -0.76156676]]
# [[ 0.17501129 0.32364586 1.561118 ]
# random
# [-1.7232178 1.1545963 -0.76156676]]
# random
mean_tensor = paddle.to_tensor(np.array([1.0, 2.0, 3.0]))
out2 = paddle.normal(mean=mean_tensor)
# [ 0.18644847 -1.19434458 3.93694787]
# [ 0.18644847 -1.19434458 3.93694787]
# random
std_tensor = paddle.to_tensor(np.array([1.0, 2.0, 3.0]))
out3 = paddle.normal(mean=mean_tensor, std=std_tensor)
# [1.00780561 3.78457445 5.81058198]
# [1.00780561 3.78457445 5.81058198]
# random
doc/paddle/api/paddle/tensor/random/rand_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -5,11 +5,6 @@ rand
.. py:function:: paddle.rand(shape, dtype=None, name=None)
:alias_main: paddle.rand
:alias: paddle.tensor.rand, paddle.tensor.random.rand
该OP返回符合均匀分布的,范围在[0, 1)的Tensor,形状为 ``shape``,数据类型为 ``dtype``。
参数
...
...
@@ -22,11 +17,6 @@ rand
::::::::::
Tensor: 符合均匀分布的范围为[0, 1)的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
抛出异常
::::::::::
- ``TypeError`` - 如果 ``shape`` 的类型不是list、tuple、Tensor。
- ``TypeError`` - 如果 ``dtype`` 不是float32、float64。
示例代码
::::::::::
...
...
@@ -35,25 +25,25 @@ rand
import paddle
import numpy as np
paddle.
enable_imperative
()
paddle.
disable_static
()
# example 1: attr shape is a list which doesn't contain Tensor.
result_
1 = paddle.rand(shape=[2, 3])
# [[0.451152 , 0.55825245, 0.403311 ],
# [0.22550228, 0.22106001, 0.7877319 ]]
out
1 = paddle.rand(shape=[2, 3])
# [[0.451152 , 0.55825245, 0.403311 ],
# random
# [0.22550228, 0.22106001, 0.7877319 ]]
# random
# example 2: attr shape is a list which contains Tensor.
dim
_1 = paddle.fill_constant([1], "int64", 2
)
dim
_2 = paddle.fill_constant([1], "int32", 3
)
result_2 = paddle.rand(shape=[dim_1, dim_
2, 2])
# [[[0.8879919
0.25788337]
# [0.28826773
0.9712097 ]
# [0.26438272
0.01796806]]
# [[0.33633623
0.28654453]
# [0.79109055
0.7305809 ]
# [0.870881
0.2984597 ]]]
dim
1 = paddle.full([1], 2, "int64"
)
dim
2 = paddle.full([1], 3, "int32"
)
out2 = paddle.rand(shape=[dim1, dim
2, 2])
# [[[0.8879919
, 0.25788337], # random
# [0.28826773
, 0.9712097 ], # random
# [0.26438272
, 0.01796806]], # random
# [[0.33633623
, 0.28654453], # random
# [0.79109055
, 0.7305809 ], # random
# [0.870881
, 0.2984597 ]]] # random
# example 3: attr shape is a Tensor, the data type must be int64 or int32.
var_shape = paddle.imperative.to_variable
(np.array([2, 3]))
result_3 = paddle.rand(var_shape
)
# [[0.22920267
0.841956 0.05981819]
# [0.4836288
0.24573246 0.7516129 ]]
shape_tensor = paddle.to_tensor
(np.array([2, 3]))
out2 = paddle.rand(shape_tensor
)
# [[0.22920267
, 0.841956 , 0.05981819], # random
# [0.4836288
, 0.24573246, 0.7516129 ]] # random
doc/paddle/api/paddle/tensor/random/randint_cn.rst
浏览文件 @
e613a9bc
.. _cn_api_tensor_randint:
.. _cn_api_tensor_rand
om_rand
int:
randint
-------------------------------
.. py:function:: paddle.randint(low=0, high=None, shape=[1], dtype=None, name=None)
:alias_main: paddle.randint
:alias: paddle.tensor.randint, paddle.tensor.random.randint
该OP返回服从均匀分布的、范围在[``low``, ``high``)的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。当 ``high`` 为None时(默认),均匀采样的区间为[0, ``low``)。
参数
...
...
@@ -24,12 +19,6 @@ randint
::::::::::
Tensor:从区间[``low``,``high``)内均匀分布采样的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
抛出异常
::::::::::
- ``TypeError`` - 如果 ``shape`` 的类型不是list、tuple、Tensor。
- ``TypeError`` - 如果 ``dtype`` 不是int32、int64。
- ``ValueError`` - 如果 ``high`` 不大于 ``low``;或者 ``high`` 为None,且 ``low`` 不大于0。
代码示例
:::::::::::
...
...
@@ -38,35 +27,34 @@ randint
import paddle
import numpy as np
paddle.
enable_imperative
()
paddle.
disable_static
()
# example 1:
# attr shape is a list which doesn't contain Tensor.
result_
1 = paddle.randint(low=-5, high=5, shape=[3])
# [0, -3, 2]
out
1 = paddle.randint(low=-5, high=5, shape=[3])
# [0, -3, 2]
# random
# example 2:
# attr shape is a list which contains Tensor.
dim_1 = paddle.fill_constant([1], "int64", 2)
dim_2 = paddle.fill_constant([1], "int32", 3)
result_2 = paddle.randint(low=-5, high=5, shape=[dim_1, dim_2], dtype="int32")
print(result_2.numpy())
# [[ 0, -1, -3],
# [ 4, -2, 0]]
dim1 = paddle.full([1], 2, "int64")
dim2 = paddle.full([1], 3, "int32")
out2 = paddle.randint(low=-5, high=5, shape=[dim1, dim2], dtype="int32")
# [[0, -1, -3], # random
# [4, -2, 0]] # random
# example 3:
# attr shape is a Tensor
var_shape = paddle.imperative.to_variable
(np.array([3]))
result_3 = paddle.randint(low=-5, high=5, shape=var_shape
)
# [-2, 2, 3]
shape_tensor = paddle.to_tensor
(np.array([3]))
out3 = paddle.randint(low=-5, high=5, shape=shape_tensor
)
# [-2, 2, 3]
# random
# example 4:
# dat
e
type is int32
result_
4 = paddle.randint(low=-5, high=5, shape=[3], dtype='int32')
# [-5, 4, -4]
# dat
a
type is int32
out
4 = paddle.randint(low=-5, high=5, shape=[3], dtype='int32')
# [-5, 4, -4]
# random
# example 5:
# Input only one parameter
# low=0, high=10, shape=[1], dtype='int64'
result_
5 = paddle.randint(10)
# [7]
out
5 = paddle.randint(10)
# [7]
# random
doc/paddle/api/paddle/tensor/random/randn_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -5,11 +5,6 @@ randn
.. py:function:: paddle.randn(shape, dtype=None, name=None)
:alias_main: paddle.randn
:alias: paddle.tensor.randn, paddle.tensor.random.randn
该OP返回符合标准正态分布(均值为0,标准差为1的正态随机分布)的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
参数
...
...
@@ -22,11 +17,6 @@ randn
::::::::::
Tensor:符合标准正态分布的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
抛出异常
::::::::::
- ``TypeError`` - 如果 ``shape`` 的类型不是list、tuple、Tensor。
- ``TypeError`` - 如果 ``dtype`` 不是float32、float64。
示例代码
::::::::::
...
...
@@ -35,26 +25,26 @@ randn
import paddle
import numpy as np
paddle.
enable_imperative
()
paddle.
disable_static
()
# example 1: attr shape is a list which doesn't contain Tensor.
result_
1 = paddle.randn(shape=[2, 3])
# [[-2.923464
0.11934398 -0.51249987]
# [ 0.39632758
0.08177969 0.2692008 ]]
out
1 = paddle.randn(shape=[2, 3])
# [[-2.923464
, 0.11934398, -0.51249987], # random
# [ 0.39632758
, 0.08177969, 0.2692008 ]] # random
# example 2: attr shape is a list which contains Tensor.
dim
_1 = paddle.fill_constant([1], "int64", 2
)
dim
_2 = paddle.fill_constant([1], "int32", 3
)
result_2 = paddle.randn(shape=[dim_1, dim_
2, 2])
# [[[-2.8852394
-0.25898588]
# [-0.47420555
0.17683524]
# [-0.7989969
0.00754541]]
# [[ 0.85201347
0.32320443]
# [ 1.1399018
0.48336947]
# [ 0.8086993
0.6868893 ]]]
dim
1 = paddle.full([1], 2, "int64"
)
dim
2 = paddle.full([1], 3, "int32"
)
out2 = paddle.randn(shape=[dim1, dim
2, 2])
# [[[-2.8852394
, -0.25898588], # random
# [-0.47420555
, 0.17683524], # random
# [-0.7989969
, 0.00754541]], # random
# [[ 0.85201347
, 0.32320443], # random
# [ 1.1399018
, 0.48336947], # random
# [ 0.8086993
, 0.6868893 ]]] # random
# example 3: attr shape is a Tensor, the data type must be int64 or int32.
var_shape = paddle.imperative.to_variable
(np.array([2, 3]))
result_3 = paddle.randn(var_shape
)
# [[-2.878077
0.17099959 0.05111201]
# [-0.3761474
-1.044801 1.1870178 ]]
shape_tensor = paddle.to_tensor
(np.array([2, 3]))
out3 = paddle.randn(shape_tensor
)
# [[-2.878077
, 0.17099959, 0.05111201] # random
# [-0.3761474
, -1.044801 , 1.1870178 ]] # random
doc/paddle/api/paddle/tensor/random/randperm_cn.rst
浏览文件 @
e613a9bc
...
...
@@ -5,9 +5,6 @@ randperm
.. py:function:: paddle.randperm(n, dtype="int64", name=None)
:alias_main: paddle.randperm
:alias: paddle.tensor.randperm, paddle.tensor.random.randperm
该OP返回一个数值在0到n-1、随机排列的1-D Tensor,数据类型为 ``dtype``。
参数:
...
...
@@ -20,22 +17,17 @@ randperm
::::::::::
Tensor:一个数值在0到n-1、随机排列的1-D Tensor,数据类型为 ``dtype`` 。
抛出异常
::::::::::
- ValueError - 如果 ``n`` 不大于0.
- TypeError - 如果 ``dtype`` 不是int32、int64、float32、float64.
代码示例
::::::::::
..
code-block:: python
.. code-block:: python
import paddle
paddle.
enable_imperative
()
paddle.
disable_static
()
result_
1 = paddle.randperm(5)
# [4
1 2 3 0]
out
1 = paddle.randperm(5)
# [4
, 1, 2, 3, 0] # random
result_
2 = paddle.randperm(7, 'int32')
# [1
6 2 0 4 3 5]
out
2 = paddle.randperm(7, 'int32')
# [1
, 6, 2, 0, 4, 3, 5] # random
doc/paddle/api/paddle/tensor/random/standard_normal_cn.rst
0 → 100644
浏览文件 @
e613a9bc
.. _cn_api_tensor_random_standard_normal:
standard_normal
-------------------------------
.. py:function:: paddle.standard_normal(shape, dtype=None, name=None)
该OP返回符合标准正态分布(均值为0,标准差为1的正态随机分布)的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
参数
::::::::::
- **shape** (list|tuple|Tensor) - 生成的随机Tensor的形状。如果 ``shape`` 是list、tuple,则其中的元素可以是int,或者是形状为[1]且数据类型为int32、int64的Tensor。如果 ``shape`` 是Tensor,则是数据类型为int32、int64的1-D Tensor。
- **dtype** (str|np.dtype|core.VarDesc.VarType, 可选) - 输出Tensor的数据类型,支持float32、float64。当该参数值为None时, 输出Tensor的数据类型为float32。默认值为None.
- **name** (str, 可选) - 输出的名字。一般无需设置,默认值为None。该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` 。
返回
::::::::::
Tensor:符合标准正态分布的随机Tensor,形状为 ``shape``,数据类型为 ``dtype``。
示例代码
::::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
# example 1: attr shape is a list which doesn't contain Tensor.
out1 = paddle.standard_normal(shape=[2, 3])
# [[-2.923464 , 0.11934398, -0.51249987], # random
# [ 0.39632758, 0.08177969, 0.2692008 ]] # random
# example 2: attr shape is a list which contains Tensor.
dim1 = paddle.full([1], 2, "int64")
dim2 = paddle.full([1], 3, "int32")
out2 = paddle.standard_normal(shape=[dim1, dim2, 2])
# [[[-2.8852394 , -0.25898588], # random
# [-0.47420555, 0.17683524], # random
# [-0.7989969 , 0.00754541]], # random
# [[ 0.85201347, 0.32320443], # random
# [ 1.1399018 , 0.48336947], # random
# [ 0.8086993 , 0.6868893 ]]] # random
# example 3: attr shape is a Tensor, the data type must be int64 or int32.
shape_tensor = paddle.to_tensor(np.array([2, 3]))
out3 = paddle.standard_normal(shape_tensor)
# [[-2.878077 , 0.17099959, 0.05111201] # random
# [-0.3761474, -1.044801 , 1.1870178 ]] # random
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录