Skip to content

Commit

Permalink
Refine the documentation format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xreki committed Oct 9, 2020
1 parent a045598 commit 7ef4659
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
12 changes: 6 additions & 6 deletions python/paddle/nn/functional/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,10 @@ def linear(x, weight, bias=None, name=None):
where :math:`W` is the weight and :math:`b` is the bias.
If the weight is a 2-D tensor of shape :math:`[in\_features, out\_features]` ,
input should be a multi-dimensional tensor of shape :math:`[N, *, in\_features]` ,
where :math:`N` is batch size and :math:`*` means any number of additional
dimensions. The linear operator multiplies input tensor with weight and produces an
output tensor of shape :math:`[N, *, out\_features]` ,
input should be a multi-dimensional tensor of shape
:math:`[batch\_size, *, in\_features]` , where :math:`*` means any number of
additional dimensions. The linear operator multiplies input tensor with
weight and produces an output tensor of shape :math:`[batch\_size, *, out\_features]` ,
If :math:`bias` is not None, the bias should be a 1-D tensor of shape
:math:`[out\_features]` and will be added to the output.
Expand All @@ -1432,8 +1432,8 @@ def linear(x, weight, bias=None, name=None):
For detailed information, please refer to :ref:`api_guide_Name` .
Returns:
A multi-dimentional tensor of the shape :math:`[N, *, out\_features]` and with
the same data type of input :math:`x` .
Tensor, the shape is :math:`[batch\_size, *, out\_features]` and the
data type is the same with input :math:`x` .
Examples:
.. code-block:: python
Expand Down
31 changes: 16 additions & 15 deletions python/paddle/nn/layer/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,37 @@ class Linear(layers.Layer):
where :math:`W` is the weight and :math:`b` is the bias.
Linear layer takes only one multi-dimensional tensor as input with the
shape :math:`[N, *, in\_features]` , where :math:`N` is batch size and
:math:`*` means any number of additional dimensions. It multiplies
input tensor with the weight (a 2-D tensor of shape
:math:`[in\_features, out\_features]` ) and produces an output tensor of
shape :math:`[N, *, out\_features]` . If :math:`bias\_attr` is not False,
the bias (a 1-D tensor of shape :math:`[out\_features]` ) will be created
and added to the output.
shape :math:`[batch\_size, *, in\_features]` , where :math:`*` means any
number of additional dimensions. It multiplies input tensor with the weight
(a 2-D tensor of shape :math:`[in\_features, out\_features]` ) and produces
an output tensor of shape :math:`[batch\_size, *, out\_features]` .
If :math:`bias\_attr` is not False, the bias (a 1-D tensor of
shape :math:`[out\_features]` ) will be created and added to the output.
Parameters:
in_features (int): The number of input units.
out_features (int): The number of output units.
weight_attr (ParamAttr, optional): The attribute for the learnable
weight of this layer. The default value is None and the weight will be
initialized to zero. For detailed information, please refer to
:ref:`api_paddle_fluid_param_attr_ParamAttr` .
paddle.ParamAttr.
bias_attr (ParamAttr|bool, optional): The attribute for the learnable bias
of this layer. If it is set to False, no bias will be added to the output.
If it is set to None or one kind of ParamAttr, a bias parameter will
be created according to ParamAttr. For detailed information, please refer
to :ref:`api_paddle_fluid_param_attr_ParamAttr` . The default value is None
and the bias will be initialized to zero.
to paddle.ParamAttr. The default value is None and the bias will be
initialized to zero.
name (str, optional): Normally there is no need for user to set this parameter.
For detailed information, please refer to :ref:`api_guide_Name` .
Attributes:
weight (Parameter): the learnable weights of this layer.
bias (Parameter): the learnable bias of this layer.
Attribute:
**weight** (Parameter): the learnable weight of this layer.
Returns:
A multi-dimentional tensor of the shape :math:`[N, *, out\_features]` .
**bias** (Parameter): the learnable bias of this layer.
Shape:
- input: Multi-dimentional tensor with shape :math:`[batch\_size, *, in\_features]` .
- output: Multi-dimentional tensor with shape :math:`[batch\_size, *, out\_features]` .
Examples:
.. code-block:: python
Expand Down

0 comments on commit 7ef4659

Please sign in to comment.