提交 c322c7bb 编写于 作者: C caoying03

some small refines.

上级 66468736
...@@ -81,15 +81,15 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -81,15 +81,15 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker {
"(int, default 1) " "(int, default 1) "
R"DOC(The mul_op can take tensors with more than two dimensions as its R"DOC(The mul_op can take tensors with more than two dimensions as its
inputs. If the input `X` is a tensor with more than two inputs. If the input `X` is a tensor with more than two
dimensions, `X` will be flatten into a two-dimensional matrix dimensions, `X` will be flattened into a two-dimensional matrix
first. The flatten rule is: the first `num_col_dims` will be first. The flattening rule is: the first `num_col_dims` will be
flatten to form the first dimension of the matrix (height of the flattened to form the first dimension of the final matrix (height
matrix), and the rest `rank(X) - num_col_dims` dimensions are of the matrix), and the rest `rank(X) - num_col_dims` dimensions
flattened to form the second dimension of the matrix (width of the are flattened to form the second dimension of the final matrix (
matrix). As a result, height of the flattened matrix is equal to width of the matrix). As a result, height of the flattened matrix
the product of `X`'s first `x_num_col_dims` dimensions' sizes, is equal to the product of `X`'s first `x_num_col_dims` dimensions'
and width of the flattened matrix is equal to the product of `X`'s sizes, and width of the flattened matrix is equal to the product
last `rank(x) - num_col_dims` dimensions' size. of `X`'s last `rank(x) - num_col_dims` dimensions' size.
For example, suppose `X` is a 6-dimensional tensor with the shape For example, suppose `X` is a 6-dimensional tensor with the shape
[2, 3, 4, 5, 6], and `x_num_col_dims` = 3. Then, the flattened [2, 3, 4, 5, 6], and `x_num_col_dims` = 3. Then, the flattened
matrix will have a shape [2 x 3 x 4, 5 x 6] = [24, 30]. matrix will have a shape [2 x 3 x 4, 5 x 6] = [24, 30].
...@@ -102,9 +102,8 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -102,9 +102,8 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker {
R"DOC(The mul_op can take tensors with more than two dimensions as its R"DOC(The mul_op can take tensors with more than two dimensions as its
inputs. If the input `Y` is a tensor with more than two inputs. If the input `Y` is a tensor with more than two
dimensions, `Y` will be flatten into a two-dimensional matrix dimensions, `Y` will be flatten into a two-dimensional matrix
first. The attribute `y_num_col_dims` is used to flatten `Y` into first. The attribute `y_num_col_dims` determines how `Y` is
a two-dimensional matrix. See the comments of `x_num_col_dims` for flattened. See comments of `x_num_col_dims` for more details.
more details.
)DOC") )DOC")
.SetDefault(1) .SetDefault(1)
.EqualGreaterThan(1); .EqualGreaterThan(1);
......
...@@ -55,24 +55,27 @@ def fc(input, ...@@ -55,24 +55,27 @@ def fc(input,
act: Activation to be applied to the output of the fully connected layer. act: Activation to be applied to the output of the fully connected layer.
name: Name/alias of the fully connected layer. name: Name/alias of the fully connected layer.
The fully connected can take multiple tensor as inputs. It creates a The fully connected layer can take multiple tensors as its inputs. It
variable (one for each input tensor) called weights which represents a creates a variable (one for each input tensor) called weights for each input
fully connected weight matrix from each input unit to each output unit. tensor, which represents a fully connected weight matrix from each input
The fully connected layer multiplies each input tensor with its coresponding unit to each output unit. The fully connected layer multiplies each input
weight to produce an output Tensor. If multiple input tensors are given, tensor with its coresponding weight to produce an output Tensor. If
the results of multiple multiplications will be sumed up. If bias_attr is multiple input tensors are given, the results of multiple multiplications
not None, a biases variable will be created and added to the output. will be sumed up. If bias_attr is not None, a biases variable will be
Finally, if activation is not None, it will be applied to the output as well. created and added to the output. Finally, if activation is not None,
it will be applied to the output as well.
This process canbe formulated as follows:
This process can be formulated as follows:
.. math:: .. math::
Y = \sigma({\sum_{i=0}^{N-1}W_iX_i + b}) Y = \sigma({\sum_{i=0}^{N-1}W_iX_i + b})
where, :math:`N` is the number of input, :math:`X_i` is the input tensor, where, :math:`N` is the number of input, :math:`X_i` is the input tensor,
:math`W` is the weights created by this layer, :math:`b` is the bias. :math:`W` is the weights created by this layer, :math:`b` is the bias
created by this layer (if needed), :math:`\sigma` is the activation funtion.
""" """
helper = LayerHelper("fc", **locals()) helper = LayerHelper("fc", **locals())
dtype = helper.input_dtype() dtype = helper.input_dtype()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册