Skip to content

Commit fc0f92c

Browse files
author
ranqiu
committed
Update api doc std and fc doc
1 parent a78b760 commit fc0f92c

File tree

3 files changed

+30
-46
lines changed

3 files changed

+30
-46
lines changed

doc/fluid/dev/api_doc_std_cn.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ API文档须包含以下几个模块(排列顺序为文档撰写顺序):
4040

4141
## 格式及示例
4242

43-
API文档须使用rst格式撰写,该格式详情请参考[链接](http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html)。API文档各模块的内容格式及示例如下(以下以fc为例进行说明):
43+
API文档须使用reStructuredText格式撰写,该格式详情请参考[链接](http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html)。API文档各模块的内容格式及示例如下(以下以fc为例进行说明):
4444

4545
- Python API Definition
4646

@@ -137,7 +137,8 @@ API文档须使用rst格式撰写,该格式详情请参考[链接](http://sphi
137137
138138
```
139139
Args:
140-
input (Variable|list of Variable): This layer's input tensor(s) which is at least 2-dimensional.
140+
input (Variable|list of Variable): The input tensor(s) of this layer, and the dimension of
141+
the input tensor(s) is at least 2.
141142
param_attr (ParamAttr|list of ParamAttr, default None): The parameter attribute for learnable
142143
parameters/weights of this layer.
143144
name (str, default None): The name of this layer.

doc/fluid/dev/src/fc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def fc(input,
4848
* :math:`Out`: The output tensor.
4949
5050
Args:
51-
input (Variable|list of Variable): This layer's input tensor(s) which is at least 2-dimensional.
51+
input (Variable|list of Variable): The input tensor(s) of this layer, and the dimension of
52+
the input tensor(s) is at least 2.
5253
size(int): The number of output units in this layer.
5354
num_flatten_dims (int, default 1): The fc layer can accept an input tensor with more than
5455
two dimensions. If this happens, the multidimensional tensor will first be flattened

python/paddle/fluid/layers/nn.py

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ def fc(input,
8585
**Fully Connected Layer**
8686
8787
The fully connected layer can take multiple tensors as its inputs. It
88-
creates a variable (one for each input tensor) called weights for each
89-
input tensor, which represents a fully connected weight matrix from
90-
each input unit to each output unit. The fully connected layer
91-
multiplies each input tensor with its coresponding weight to produce
92-
an output Tensor. If multiple input tensors are given, the results of
93-
multiple multiplications will be sumed up. If bias_attr is not None,
94-
a biases variable will be created and added to the output. Finally,
88+
creates a variable called weights for each input tensor, which represents
89+
a fully connected weight matrix from each input unit to each output unit.
90+
The fully connected layer multiplies each input tensor with its coresponding
91+
weight to produce an output Tensor. If multiple input tensors are given,
92+
the results of multiple multiplications will be sumed up. If bias_attr is
93+
not None, a bias variable will be created and added to the output. Finally,
9594
if activation is not None, it will be applied to the output as well.
9695
9796
This process can be formulated as follows:
@@ -110,44 +109,27 @@ def fc(input,
110109
* :math:`Out`: The output tensor.
111110
112111
Args:
113-
input(Variable|list): The input tensor(s) to the fully connected layer.
114-
size(int): The number of output units in the fully connected layer.
115-
num_flatten_dims(int): The fc layer can accept an input tensor with more
116-
than two dimensions. If this happens, the
117-
multidimensional tensor will first be flattened
118-
into a 2-dimensional matrix. The parameter
119-
`num_flatten_dims` determines how the input tensor
120-
is flattened: the first `num_flatten_dims`
121-
(inclusive, index starts from 1) dimensions will
122-
be flatten to form the first dimension of the
123-
final matrix (height of the matrix), and the rest
124-
`rank(X) - num_flatten_dims` dimensions are
125-
flattened to form the second dimension of the
126-
final matrix (width of the matrix). For example,
127-
suppose `X` is a 6-dimensional tensor with a shape
128-
[2, 3, 4, 5, 6], and `num_flatten_dims` = 3. Then,
129-
the flattened matrix will have a shape
130-
[2 x 3 x 4, 5 x 6] = [24, 30]. By default,
131-
`num_flatten_dims` is set to 1.
132-
param_attr(ParamAttr|list): The parameter attribute for learnable
133-
parameters/weights of the fully connected
134-
layer.
135-
param_initializer(ParamAttr|list): The initializer used for the
136-
weight/parameter. If set None,
137-
XavierInitializer() will be used.
138-
bias_attr(ParamAttr|list): The parameter attribute for the bias parameter
139-
for this layer. If set None, no bias will be
140-
added to the output units.
141-
bias_initializer(ParamAttr|list): The initializer used for the bias.
142-
If set None, then ConstantInitializer()
143-
will be used.
144-
act(str): Activation to be applied to the output of the fully connected
145-
layer.
146-
name(str): Name/alias of the fully connected layer.
147-
112+
input (Variable|list of Variable): The input tensor(s) of this layer, and the dimension of
113+
the input tensor(s) is at least 2.
114+
size(int): The number of output units in this layer.
115+
num_flatten_dims (int, default 1): The fc layer can accept an input tensor with more than
116+
two dimensions. If this happens, the multidimensional tensor will first be flattened
117+
into a 2-dimensional matrix. The parameter `num_flatten_dims` determines how the input
118+
tensor is flattened: the first `num_flatten_dims` (inclusive, index starts from 1)
119+
dimensions will be flatten to form the first dimension of the final matrix (height of
120+
the matrix), and the rest `rank(X) - num_flatten_dims` dimensions are flattened to
121+
form the second dimension of the final matrix (width of the matrix). For example, suppose
122+
`X` is a 6-dimensional tensor with a shape [2, 3, 4, 5, 6], and `num_flatten_dims` = 3.
123+
Then, the flattened matrix will have a shape [2 x 3 x 4, 5 x 6] = [24, 30].
124+
param_attr (ParamAttr|list of ParamAttr, default None): The parameter attribute for learnable
125+
parameters/weights of this layer.
126+
bias_attr (ParamAttr|list of ParamAttr, default None): The parameter attribute for the bias
127+
of this layer. If it is set to None, no bias will be added to the output units.
128+
act (str, default None): Activation to be applied to the output of this layer.
129+
name (str, default None): The name of this layer.
148130
149131
Returns:
150-
Variable: The output tensor variable.
132+
A tensor variable storing the transformation result.
151133
152134
Raises:
153135
ValueError: If rank of the input tensor is less than 2.

0 commit comments

Comments
 (0)