From c5c024377bf4b76bbb7466c057d4cbd28b275241 Mon Sep 17 00:00:00 2001 From: kexinzhao <19hskevin87@gmail.com> Date: Fri, 3 Nov 2017 19:11:00 -0700 Subject: [PATCH] Polish from concat to conv shift operators (#5347) * polish from concat to conv_shift op doc * small fix * small fix --- paddle/operators/concat_op.cc | 30 +++++++++++++---------- paddle/operators/cond_op.cc | 11 +++++---- paddle/operators/conv2d_op.cc | 32 ++++++++++++++----------- paddle/operators/conv2d_transpose_op.cc | 18 ++++++++------ paddle/operators/conv_shift_op.cc | 11 ++++----- 5 files changed, 57 insertions(+), 45 deletions(-) diff --git a/paddle/operators/concat_op.cc b/paddle/operators/concat_op.cc index e11e51b458..5f05268925 100644 --- a/paddle/operators/concat_op.cc +++ b/paddle/operators/concat_op.cc @@ -56,20 +56,24 @@ class ConcatOpMaker : public framework::OpProtoAndCheckerMaker { public: ConcatOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker) : OpProtoAndCheckerMaker(proto, op_checker) { - AddInput("X", "the input tensors of concat operator.").AsDuplicable(); - AddOutput("Out", "the output tensor of concat operator."); - AddComment(R"DOC( - Join the input tensors along with the axis. - Examples: - Input[0] = [[1,2],[3,4]] - Input[1] = [[5,6]] - axis = 0 - Output = [[1,2], - [3,4], - [5,6]] - )DOC"); - AddAttr("axis", "The axis which the inputs will be joined with.") + AddInput("X", "Input tensors of concat operator.").AsDuplicable(); + AddOutput("Out", "Output tensor of concat operator."); + AddAttr("axis", + "The axis along which the input tensors will be concatenated.") .SetDefault(0); + AddComment(R"DOC( +Concat Operator. + +Concatenate the input tensors along dimension axis. +Examples: + Input[0] = [[1,2],[3,4]] + Input[1] = [[5,6]] + axis = 0 + Output = [[1,2], + [3,4], + [5,6]] + +)DOC"); } }; diff --git a/paddle/operators/cond_op.cc b/paddle/operators/cond_op.cc index adcd867f50..b809bdc3a0 100644 --- a/paddle/operators/cond_op.cc +++ b/paddle/operators/cond_op.cc @@ -216,11 +216,12 @@ class CondOpProtoAndCheckerMaker : public framework::OpProtoAndCheckerMaker { AddOutput("IndexTensors", "Index Tensors contains indices for true/false"); AddComment(R"DOC( -Sample dependent Cond Operator: -Given Cond[i] as a 1/0 vector to indicate true/false -The equation is: -Out[i] = subnet_t[i], if Cond[i] == true -Out[i] = subnet_t[i], if Cond[i] == false +Sample Dependent Conditional Operator. + +Given Cond[i] as a 1/0 vector to indicate true/false: +Out[i] = subnet_true[i], if Cond[i] == true +Out[i] = subnet_false[i], if Cond[i] == false + )DOC"); } }; diff --git a/paddle/operators/conv2d_op.cc b/paddle/operators/conv2d_op.cc index 1acb8415d0..b47cff180d 100644 --- a/paddle/operators/conv2d_op.cc +++ b/paddle/operators/conv2d_op.cc @@ -56,17 +56,18 @@ Conv2DOpMaker::Conv2DOpMaker(framework::OpProto* proto, AddInput( "Input", "The input tensor of convolution operator. " - "The format of input tensor is NCHW. Where N is batch size, C is the " - "number of channels, H and W is the height and width of image."); + "The format of input tensor is NCHW, where N is batch size, C is the " + "number of channels, H is the height of the image, " + "and W is the width of the image."); AddInput("Filter", - "The filter tensor of convolution operator." + "The filter tensor of convolution operator. " "The format of the filter tensor is MCHW, where M is the number of " "output image channels, C is the number of input image channels, " - "H and W is height and width of filter. " - "If the groups attribute is greater than 1, C equal the number of " + "H is the height of the filter, and W is the width of the filter. " + "If the groups attribute is greater than 1, C equals the number of " "input image channels divided by the groups."); AddOutput("Output", - "The output tensor of convolution operator." + "The output tensor of convolution operator. " "The format of output tensor is also NCHW."); AddAttr>("strides", "strides of convolution operator.") .SetDefault({1, 1}); @@ -74,16 +75,19 @@ Conv2DOpMaker::Conv2DOpMaker(framework::OpProto* proto, .SetDefault({0, 0}); AddAttr( "groups", - "group size of convolution operator. " - "Refer to grouped convolution in Alex Krizhevsky's paper: " - "when group=2, the first half of the filters are only connected to the " - "first half of the input channels, and the second half only connected " - "to the second half.") + "Group size of convolution operator. " + "According to grouped convolution in Alex Krizhevsky's Deep CNN paper: " + "when group=2, the first half of the filters is only connected to the " + "first half of the input channels, while the second half of the filters " + "is only connected to the second half of the input channels.") .SetDefault(1); AddComment(R"DOC( -The convolution operation calculates the output based on the input, filter -and strides, paddings, groups parameters. The size of each dimension of the -parameters is checked in the infer-shape. +Convolution Operator. + +The convolution operation calculates the output based on the input, filter, +strides, paddings, and groups parameters. The size of each dimension of the +parameters is checked in the infer-shape method. + )DOC"); } diff --git a/paddle/operators/conv2d_transpose_op.cc b/paddle/operators/conv2d_transpose_op.cc index 348527728b..8f5d18cddf 100644 --- a/paddle/operators/conv2d_transpose_op.cc +++ b/paddle/operators/conv2d_transpose_op.cc @@ -54,15 +54,16 @@ Conv2DTransposeOpMaker::Conv2DTransposeOpMaker( AddInput( "Input", "(Tensor) The input tensor of convolution transpose operator. " - "The format of input tensor is NCHW. Where N is batch size, C is the " - "number of input channels, H and W is the height and width of image."); + "The format of input tensor is NCHW, where N is batch size, C is the " + "number of input channels, H is the height of the image, and " + "W is the width of the image."); AddInput("Filter", "(Tensor) The filter tensor of convolution transpose operator." "The format of the filter tensor is CMHW, where C is the number of " "output image channels, M is the number of input image channels, " - "H and W is height and width of filter. " + "H is the height of the filter, and W is the width of the filter. " "We enforce groups number == 1 and padding == 0 in " - "convolution transpose Scenario."); + "the convolution transpose scenario."); AddOutput("Output", "(Tensor) The output tensor of convolution transpose operator." "The format of output tensor is also NCHW."); @@ -73,9 +74,12 @@ Conv2DTransposeOpMaker::Conv2DTransposeOpMaker( "paddings of convolution transpose operator.") .SetDefault({0, 0}); AddComment(R"DOC( -The convolution transpose operation calculates the output based on the input, filter -and strides, paddings, groups parameters. The size of each dimension of the -parameters is checked in the infer-shape. +Convolution Transpose Operator. + +The convolution transpose operation calculates the output based on the input, +filter, strides, paddings, and groups parameters. The size of each dimension +of the parameters is checked in the infer-shape method. + )DOC"); } diff --git a/paddle/operators/conv_shift_op.cc b/paddle/operators/conv_shift_op.cc index 6156a2d6af..a4150a5664 100644 --- a/paddle/operators/conv_shift_op.cc +++ b/paddle/operators/conv_shift_op.cc @@ -96,14 +96,13 @@ as used in the Neural Turing Machine: https://arxiv.org/abs/1410.5401 The equation is: - \f[ - Out[i] = \sum_{j=-(N-1)/2}^{(N-1)/2} X_{i+j} * Y_{j} - \f] +$$Out[i] = \sum_{j=-(N-1)/2}^{(N-1)/2} X_{i+j} * Y_{j}$$ -where X's index is computed modulo M, and b's index is computed modulo N. +where X's index is computed modulo M, and Y's index is computed modulo N. + +Both inputs X and Y can carry LoD (Level of Details) information. +However, the output only shares the LoD information with input X. -Both of the input `X` and `Y` can carry LoD (Level of Details) information. -However, the output only shares the LoD information with input `X`. )DOC"); } }; -- GitLab