Skip to content

Polish documents for fluid operators. #6526

@pkuyym

Description

@pkuyym

We have to polish the documents for fluid operators. This issue takes fc as an example to show the documentation specification.

python/paddle/v2/fluid/layers.py#fc

def fc(input,
       size,
       num_flatten_dims=1,
       param_attr=None,
       bias_attr=None,
       act=None,
       name=None,
       main_program=None,
       startup_program=None):
    """Fully Connected Layer. This layer accepts multiple inputs and applies
    linear transformation to each input data. If activation type provided,
    corresponding nonlinear transformation would be applied then. For each input
    :math:`X`, the equation is:

    .. math::

        Out = Act(WX + b)

    In the above equation:

        * :math:`X`: Input value, a tensor with rank at least 2.
        * :math:`W`: Weight, a 2-D tensor with shape [M, N].
        * :math:`b`: Bias, a 2-D tensor with shape [M, 1].
        * :math:`Act`: Activation function.
        * :math:`Out`: Output value, same shape with :math:`X`.

    All the input variables are passed in as local variables to the LayerHelper
    constructor.

    Args:
        Input (Variable|list): The input values, each value is a tensor with
            rank at least 2.
        size (int): The output size, an interge value.
        num_flatten_dims (int): Column number of the input.
        param_attr (ParamAttr|list): The parameters/weights to the FC Layer.
        bias_attr (ParamAttr|list): The bias parameter.
        act (str): Activation type.
        name (str): Name/alias of the function.
        main_program (Program): The main program calling this.
        startup_program (Program): The startup program.

    Returns:
        Variable: The tensor variable storing the transformation and \
                  non-linearity activation result.

    Raises:
        ValueError: If rank of input tensor is less than 2.

    Examples:
        .. code-block:: python

          data = fluid.layers.data(name='data', shape=[32, 32], dtype='float32')
          fc = fluid.layers.fc(input=data, size=1000, act="tanh")
    """

And the final html looks like:

fc_example

How to preview

After refined the documents in layers.py, we need to preview the html page. Here I list some key tips:

  1. Go to build directory.
  2. Please make sure WITH_DOC=1 and sphinx==1.5.6.
  3. make -j `nproc` && python -m SimpleHTTPServer $PORT_NUM
  4. Assume that PaddlePaddle is compiled on computer with ip being $IP. We can visit $IP:$PORT_NUM/doc/en/html/api/v2/fluid/layers.html to check the preview.
  5. Add link in doc/api/v2/fluid/layers.rst

URLs

Docs of sphnix: http://www.sphinx-doc.org/en/stable/contents.html
How to insert codes: http://www.sphinx-doc.org/en/stable/markup/code.html
How to insert math equations: http://www.sphinx-doc.org/en/stable/ext/math.html
Previous discussion: #6160

Operators need to polish

Please create an issue first before do polishing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions