未验证 提交 5b6b88ab 编写于 作者: zhouweiwei2014's avatar zhouweiwei2014 提交者: GitHub

fix english doc of some API (#38468)

上级 1ab5c511
...@@ -1148,13 +1148,14 @@ def _global_bias_initializer(): ...@@ -1148,13 +1148,14 @@ def _global_bias_initializer():
def calculate_gain(nonlinearity, param=None): def calculate_gain(nonlinearity, param=None):
""" """
Get the recommended gain value of some nonlinearity function. Get the recommended ``gain`` value of some nonlinearity function. ``gain`` value can be used in some
``paddle.nn.initializer`` api to adjust the initialization value.
Args: Args:
nonlinearity(str): name of nonlinearity activation function. If it is a linear function, which is one of nonlinearity(str): name of nonlinearity activation function. If it is a linear function, such as:
"linear/conv1d/conv2d/conv3d/conv1d_transpose/conv2d_transpose/conv3d_transpose" , 1.0 will be returned. `linear/conv1d/conv2d/conv3d/conv1d_transpose/conv2d_transpose/conv3d_transpose` , 1.0 will be returned.
param(bool|int|float, optional): optional parameter for somme nonlinearity function. Now, it only applies to param(bool|int|float, optional): optional parameter for somme nonlinearity function. Now, it only applies to
'leaky_relu'. Default: None, it will be calculated as 0.01 in the formula. 'leaky_relu'. Default: None, it will be calculated as 0.01 in the formula.
Returns: Returns:
A float value, which is the recommended gain for this nonlinearity function. A float value, which is the recommended gain for this nonlinearity function.
......
...@@ -31,12 +31,13 @@ class Dirac(Initializer): ...@@ -31,12 +31,13 @@ class Dirac(Initializer):
.. math:: .. math::
Assuming: N=min(in\_channels, out\_channels)
X[d, d, shape[2]//2, shape[3]//2, ...]=1, \ d=0,1...N X[d, d, shape[2]//2, shape[3]//2, ...]=1, \ d=0,1...N
where, ``N`` is the minimum value of ``in_channels`` and ``out_channels``
Args: Args:
groups(int): 0-dimension of the Tensor will be divided by groups, each group has the same value. groups(int, optional): 0-dimension of the Tensor will be divided by groups,
each group has the same value. Default: 1.
name(str, optional): The default value is None. Normally there is no need for user to set this name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`. property. For more information, please refer to :ref:`api_guide_Name`.
......
...@@ -24,18 +24,24 @@ __all__ = [] ...@@ -24,18 +24,24 @@ __all__ = []
class Orthogonal(Initializer): class Orthogonal(Initializer):
"""The orthogonal initializer. The initialized tensor is (semi) orthogonal. """The orthogonal initializer. The initialized tensor is (semi) orthogonal.
Assuming that 'weight' will be initialized, its shape is [M, N]. It's only applied to Tensor whose dimension is greater than or equal to 2.
For the Tensor whose dimension is greater than 2, the 0 dimension is seen as ``rows`` ,
and the >=1 dimension are flattened as ``cols`` .
Which can be describe as:
.. code-block:: text .. code-block:: text
if M < N: rows = shape[0]
cols = shape[1]·shape[2]···shape[N]
if rows < cols:
The rows are orthogonal vectors The rows are orthogonal vectors
elif M > N: elif rows > cols:
The columns are orthogonal vectors The columns are orthogonal vectors
else M = N: else rows = cols:
Both rows and columns are orthogonal vectors Both rows and columns are orthogonal vectors
Only Tensor with 2 or more dimensions can initialized by Orthogonal.
Args: Args:
gain(float, optional): The multiplication coefficient for initialized tensor. Default: 1.0. gain(float, optional): The multiplication coefficient for initialized tensor. Default: 1.0.
......
...@@ -76,10 +76,10 @@ def parameters_to_vector(parameters, name=None): ...@@ -76,10 +76,10 @@ def parameters_to_vector(parameters, name=None):
@dygraph_only @dygraph_only
def vector_to_parameters(vec, parameters, name=None): def vector_to_parameters(vec, parameters, name=None):
""" """
Transform a Tensor with 1-D shape to the parameters. Transform a 1-D Tensor to the input ``parameters`` .
Args: Args:
vec (Tensor): A Tensor with 1-D shape, which represents the parameters of a Layer. vec (Tensor): A 1-D Tensor, which will be sliced and copied to the input ``parameters`` .
parameters (Iterable[Tensor]): Iterable Tensors that are trainable parameters of a Layer. parameters (Iterable[Tensor]): Iterable Tensors that are trainable parameters of a Layer.
name(str, optional): The default value is None. Normally there is no need for user to set this name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`. property. For more information, please refer to :ref:`api_guide_Name`.
......
...@@ -85,7 +85,7 @@ def poisson(x, name=None): ...@@ -85,7 +85,7 @@ def poisson(x, name=None):
.. math:: .. math::
out_i ~ Poisson (x_i) out_i \sim Poisson (lambda = x_i)
Args: Args:
x(Tensor): A tensor with rate parameter of poisson Distribution. The data type x(Tensor): A tensor with rate parameter of poisson Distribution. The data type
...@@ -101,12 +101,12 @@ def poisson(x, name=None): ...@@ -101,12 +101,12 @@ def poisson(x, name=None):
import paddle import paddle
paddle.set_device('cpu') paddle.set_device('cpu')
paddle.seed(2021) paddle.seed(100)
x = paddle.uniform([2,3], min=1.0, max=5.0) x = paddle.uniform([2,3], min=1.0, max=5.0)
out = paddle.poisson(x) out = paddle.poisson(x)
# [[2., 1., 4.], #[[2., 5., 0.],
# [4., 5., 1.]] # [5., 1., 3.]]
""" """
...@@ -994,7 +994,7 @@ def exponential_(x, lam=1.0, name=None): ...@@ -994,7 +994,7 @@ def exponential_(x, lam=1.0, name=None):
Args: Args:
x(Tensor): Input tensor. The data type should be float32, float64. x(Tensor): Input tensor. The data type should be float32, float64.
lam(float): :math:`\lambda` parameter of Exponential Distribution. lam(float, optional): :math:`\lambda` parameter of Exponential Distribution. Default, 1.0.
name(str, optional): The default value is None. Normally there is no name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`. refer to :ref:`api_guide_Name`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册