From 73632deea0fcf827a8400692d1328f97d2c52fe8 Mon Sep 17 00:00:00 2001 From: Abhinav Arora Date: Fri, 3 Nov 2017 11:48:42 -0700 Subject: [PATCH] Polish the documentation for uniform_random and top_k ops (#5353) --- paddle/operators/top_k_op.cc | 24 ++++++++++----------- paddle/operators/uniform_random_op.cc | 30 +++++++++++++++++++-------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/paddle/operators/top_k_op.cc b/paddle/operators/top_k_op.cc index ac925725954..16ae925eb5c 100644 --- a/paddle/operators/top_k_op.cc +++ b/paddle/operators/top_k_op.cc @@ -48,20 +48,20 @@ class TopkOpMaker : public framework::OpProtoAndCheckerMaker { public: TopkOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker) : OpProtoAndCheckerMaker(proto, op_checker) { - AddInput("X", "The input of Topk op"); - AddOutput("Out", "The output tensor of Topk op"); - AddOutput("Indices", "The indices of Topk elements of input"); - AddComment( - R"DOC(If the input is a vector (1d tensor), - finds the k largest entries in the vector - and outputs their values and indices as vectors. - Thus values[j] is the j-th largest entry in input, - and its index is indices[j]. + AddInput("X", "(Tensor) The input of Topk op"); + AddOutput("Out", "(Tensor) The output tensor of Topk op"); + AddOutput("Indices", "(Tensor) The indices of Topk elements of input"); + AddComment(R"DOC( +Top K operator - For matrices, computes the top k entries in each row. )DOC"); +If the input is a vector (1d tensor), this operator finds the k largest +entries in the vector and outputs their values and indices as vectors. +Thus values[j] is the j-th largest entry in input, and its index is indices[j]. + +For matrices, this operator computes the top k entries in each row. )DOC"); AddAttr("k", - "Number of top elements to look for along the last " - "dimension (along each row for matrices).") + "(int, default 1) Number of top elements to look for along " + "the last dimension (along each row for matrices).") .SetDefault(1); } }; diff --git a/paddle/operators/uniform_random_op.cc b/paddle/operators/uniform_random_op.cc index 82f9b8fbf10..cd22c561acb 100644 --- a/paddle/operators/uniform_random_op.cc +++ b/paddle/operators/uniform_random_op.cc @@ -74,18 +74,30 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker { UniformRandomOpMaker(framework::OpProto* proto, framework::OpAttrChecker* op_checker) : framework::OpProtoAndCheckerMaker(proto, op_checker) { - AddOutput("Out", "The output tensor of uniform random op"); - AddComment(R"DOC(Uniform random operator. -Used to initialize tensor with uniform random generator. + AddOutput("Out", "(Tensor) The output tensor of uniform random op"); + AddComment(R"DOC( +Uniform random operator. + +This operator initializes a tensor with random values sampled from a +uniform distribution. + )DOC"); - AddAttr>("shape", "the dimension of random tensor"); - AddAttr("min", "Minimum value of uniform random").SetDefault(-1.0f); - AddAttr("max", "Maximun value of uniform random").SetDefault(1.0f); + AddAttr>("shape", + "(vector) The shape of the output tensor"); + AddAttr("min", + "(float, default -1.0) " + "Minimum value of uniform random") + .SetDefault(-1.0f); + AddAttr("max", + "(float, default 1.0) " + "Maximun value of uniform random") + .SetDefault(1.0f); AddAttr("seed", - "Random seed of uniform random. " - "0 means generate a seed by system") + "(int, default 0) " + "Random seed used for generating samples. " + "0 means use a seed generated by the system.") .SetDefault(0); - AddAttr("data_type", "output tensor data type") + AddAttr("data_type", "(int, default 5(FP32)) Output tensor data type") .SetDefault(framework::DataType::FP32); } }; -- GitLab