Skip to content

Commit

Permalink
fix english doc of some API (PaddlePaddle#38468)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 authored Dec 27, 2021
1 parent 1ab5c51 commit 5b6b88a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
9 changes: 5 additions & 4 deletions python/paddle/fluid/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,13 +1148,14 @@ def _global_bias_initializer():

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:
nonlinearity(str): name of nonlinearity activation function. If it is a linear function, which is one of
"linear/conv1d/conv2d/conv3d/conv1d_transpose/conv2d_transpose/conv3d_transpose" , 1.0 will be returned.
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.
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:
A float value, which is the recommended gain for this nonlinearity function.
Expand Down
7 changes: 4 additions & 3 deletions python/paddle/nn/initializer/dirac.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ class Dirac(Initializer):
.. math::
Assuming: N=min(in\_channels, out\_channels)
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:
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
property. For more information, please refer to :ref:`api_guide_Name`.
Expand Down
18 changes: 12 additions & 6 deletions python/paddle/nn/initializer/orthogonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@
class Orthogonal(Initializer):
"""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
if M < N:
rows = shape[0]
cols = shape[1]·shape[2]···shape[N]
if rows < cols:
The rows are orthogonal vectors
elif M > N:
elif rows > cols:
The columns are orthogonal vectors
else M = N:
else rows = cols:
Both rows and columns are orthogonal vectors
Only Tensor with 2 or more dimensions can initialized by Orthogonal.
Args:
gain(float, optional): The multiplication coefficient for initialized tensor. Default: 1.0.
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/nn/utils/transform_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def parameters_to_vector(parameters, name=None):
@dygraph_only
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:
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.
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`.
Expand Down
10 changes: 5 additions & 5 deletions python/paddle/tensor/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def poisson(x, name=None):
.. math::
out_i ~ Poisson (x_i)
out_i \sim Poisson (lambda = x_i)
Args:
x(Tensor): A tensor with rate parameter of poisson Distribution. The data type
Expand All @@ -101,12 +101,12 @@ def poisson(x, name=None):
import paddle
paddle.set_device('cpu')
paddle.seed(2021)
paddle.seed(100)
x = paddle.uniform([2,3], min=1.0, max=5.0)
out = paddle.poisson(x)
# [[2., 1., 4.],
# [4., 5., 1.]]
#[[2., 5., 0.],
# [5., 1., 3.]]
"""

Expand Down Expand Up @@ -994,7 +994,7 @@ def exponential_(x, lam=1.0, name=None):
Args:
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
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
Expand Down

0 comments on commit 5b6b88a

Please sign in to comment.