@@ -85,13 +85,12 @@ def fc(input,
85
85
**Fully Connected Layer**
86
86
87
87
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,
95
94
if activation is not None, it will be applied to the output as well.
96
95
97
96
This process can be formulated as follows:
@@ -110,44 +109,27 @@ def fc(input,
110
109
* :math:`Out`: The output tensor.
111
110
112
111
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.
148
130
149
131
Returns:
150
- Variable: The output tensor variable.
132
+ A tensor variable storing the transformation result .
151
133
152
134
Raises:
153
135
ValueError: If rank of the input tensor is less than 2.
0 commit comments