Skip to content

Commit c5c0243

Browse files
kexinzhaowangkuiyi
authored andcommitted
Polish from concat to conv shift operators (#5347)
* polish from concat to conv_shift op doc * small fix * small fix
1 parent 45eabb8 commit c5c0243

File tree

5 files changed

+57
-45
lines changed

5 files changed

+57
-45
lines changed

paddle/operators/concat_op.cc

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,24 @@ class ConcatOpMaker : public framework::OpProtoAndCheckerMaker {
5656
public:
5757
ConcatOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker)
5858
: OpProtoAndCheckerMaker(proto, op_checker) {
59-
AddInput("X", "the input tensors of concat operator.").AsDuplicable();
60-
AddOutput("Out", "the output tensor of concat operator.");
61-
AddComment(R"DOC(
62-
Join the input tensors along with the axis.
63-
Examples:
64-
Input[0] = [[1,2],[3,4]]
65-
Input[1] = [[5,6]]
66-
axis = 0
67-
Output = [[1,2],
68-
[3,4],
69-
[5,6]]
70-
)DOC");
71-
AddAttr<int>("axis", "The axis which the inputs will be joined with.")
59+
AddInput("X", "Input tensors of concat operator.").AsDuplicable();
60+
AddOutput("Out", "Output tensor of concat operator.");
61+
AddAttr<int>("axis",
62+
"The axis along which the input tensors will be concatenated.")
7263
.SetDefault(0);
64+
AddComment(R"DOC(
65+
Concat Operator.
66+
67+
Concatenate the input tensors along dimension axis.
68+
Examples:
69+
Input[0] = [[1,2],[3,4]]
70+
Input[1] = [[5,6]]
71+
axis = 0
72+
Output = [[1,2],
73+
[3,4],
74+
[5,6]]
75+
76+
)DOC");
7377
}
7478
};
7579

paddle/operators/cond_op.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@ class CondOpProtoAndCheckerMaker : public framework::OpProtoAndCheckerMaker {
216216
AddOutput("IndexTensors", "Index Tensors contains indices for true/false");
217217

218218
AddComment(R"DOC(
219-
Sample dependent Cond Operator:
220-
Given Cond[i] as a 1/0 vector to indicate true/false
221-
The equation is:
222-
Out[i] = subnet_t[i], if Cond[i] == true
223-
Out[i] = subnet_t[i], if Cond[i] == false
219+
Sample Dependent Conditional Operator.
220+
221+
Given Cond[i] as a 1/0 vector to indicate true/false:
222+
Out[i] = subnet_true[i], if Cond[i] == true
223+
Out[i] = subnet_false[i], if Cond[i] == false
224+
224225
)DOC");
225226
}
226227
};

paddle/operators/conv2d_op.cc

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,38 @@ Conv2DOpMaker::Conv2DOpMaker(framework::OpProto* proto,
5656
AddInput(
5757
"Input",
5858
"The input tensor of convolution operator. "
59-
"The format of input tensor is NCHW. Where N is batch size, C is the "
60-
"number of channels, H and W is the height and width of image.");
59+
"The format of input tensor is NCHW, where N is batch size, C is the "
60+
"number of channels, H is the height of the image, "
61+
"and W is the width of the image.");
6162
AddInput("Filter",
62-
"The filter tensor of convolution operator."
63+
"The filter tensor of convolution operator. "
6364
"The format of the filter tensor is MCHW, where M is the number of "
6465
"output image channels, C is the number of input image channels, "
65-
"H and W is height and width of filter. "
66-
"If the groups attribute is greater than 1, C equal the number of "
66+
"H is the height of the filter, and W is the width of the filter. "
67+
"If the groups attribute is greater than 1, C equals the number of "
6768
"input image channels divided by the groups.");
6869
AddOutput("Output",
69-
"The output tensor of convolution operator."
70+
"The output tensor of convolution operator. "
7071
"The format of output tensor is also NCHW.");
7172
AddAttr<std::vector<int>>("strides", "strides of convolution operator.")
7273
.SetDefault({1, 1});
7374
AddAttr<std::vector<int>>("paddings", "paddings of convolution operator.")
7475
.SetDefault({0, 0});
7576
AddAttr<int>(
7677
"groups",
77-
"group size of convolution operator. "
78-
"Refer to grouped convolution in Alex Krizhevsky's paper: "
79-
"when group=2, the first half of the filters are only connected to the "
80-
"first half of the input channels, and the second half only connected "
81-
"to the second half.")
78+
"Group size of convolution operator. "
79+
"According to grouped convolution in Alex Krizhevsky's Deep CNN paper: "
80+
"when group=2, the first half of the filters is only connected to the "
81+
"first half of the input channels, while the second half of the filters "
82+
"is only connected to the second half of the input channels.")
8283
.SetDefault(1);
8384
AddComment(R"DOC(
84-
The convolution operation calculates the output based on the input, filter
85-
and strides, paddings, groups parameters. The size of each dimension of the
86-
parameters is checked in the infer-shape.
85+
Convolution Operator.
86+
87+
The convolution operation calculates the output based on the input, filter,
88+
strides, paddings, and groups parameters. The size of each dimension of the
89+
parameters is checked in the infer-shape method.
90+
8791
)DOC");
8892
}
8993

paddle/operators/conv2d_transpose_op.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ Conv2DTransposeOpMaker::Conv2DTransposeOpMaker(
5454
AddInput(
5555
"Input",
5656
"(Tensor) The input tensor of convolution transpose operator. "
57-
"The format of input tensor is NCHW. Where N is batch size, C is the "
58-
"number of input channels, H and W is the height and width of image.");
57+
"The format of input tensor is NCHW, where N is batch size, C is the "
58+
"number of input channels, H is the height of the image, and "
59+
"W is the width of the image.");
5960
AddInput("Filter",
6061
"(Tensor) The filter tensor of convolution transpose operator."
6162
"The format of the filter tensor is CMHW, where C is the number of "
6263
"output image channels, M is the number of input image channels, "
63-
"H and W is height and width of filter. "
64+
"H is the height of the filter, and W is the width of the filter. "
6465
"We enforce groups number == 1 and padding == 0 in "
65-
"convolution transpose Scenario.");
66+
"the convolution transpose scenario.");
6667
AddOutput("Output",
6768
"(Tensor) The output tensor of convolution transpose operator."
6869
"The format of output tensor is also NCHW.");
@@ -73,9 +74,12 @@ Conv2DTransposeOpMaker::Conv2DTransposeOpMaker(
7374
"paddings of convolution transpose operator.")
7475
.SetDefault({0, 0});
7576
AddComment(R"DOC(
76-
The convolution transpose operation calculates the output based on the input, filter
77-
and strides, paddings, groups parameters. The size of each dimension of the
78-
parameters is checked in the infer-shape.
77+
Convolution Transpose Operator.
78+
79+
The convolution transpose operation calculates the output based on the input,
80+
filter, strides, paddings, and groups parameters. The size of each dimension
81+
of the parameters is checked in the infer-shape method.
82+
7983
)DOC");
8084
}
8185

paddle/operators/conv_shift_op.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,13 @@ as used in the Neural Turing Machine: https://arxiv.org/abs/1410.5401
9696
9797
The equation is:
9898
99-
\f[
100-
Out[i] = \sum_{j=-(N-1)/2}^{(N-1)/2} X_{i+j} * Y_{j}
101-
\f]
99+
$$Out[i] = \sum_{j=-(N-1)/2}^{(N-1)/2} X_{i+j} * Y_{j}$$
102100
103-
where X's index is computed modulo M, and b's index is computed modulo N.
101+
where X's index is computed modulo M, and Y's index is computed modulo N.
102+
103+
Both inputs X and Y can carry LoD (Level of Details) information.
104+
However, the output only shares the LoD information with input X.
104105
105-
Both of the input `X` and `Y` can carry LoD (Level of Details) information.
106-
However, the output only shares the LoD information with input `X`.
107106
)DOC");
108107
}
109108
};

0 commit comments

Comments
 (0)