You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Paddle/doc/fluid/dev/api_doc_std_en.md

5.8 KiB

API Doc Standard

  • [API Doc Structure](#API Doc Structure)
  • [Format and Examples](#Format and Examples)
  • [Complete Example](#Complete Example)

API Doc Structure

API Doc should contain the following parts(please write them in order):

  • Python API Definition

    The definition of API

  • Function Description

    Description of API's function. The description includes: meaning, purpose and operation on input of API, reference and corresponding link(if any), formula(if necessary) and explanations of key variables in the formula.

  • Args Description

    Description of API parameters. Introduce parameters one by one according to the order in API definition. The introduction includes: data type, default value(if any), meaning, etc.

  • Returns

    Introduction of API returned value. Introduce meaning of returned value, provide correspoding format if necessary. If returned value is a tuple containing multiple parameters, then introduce parameters one by one in order.

  • Raisesif any

    Abnormality, error that may occur, and possible reasons. If there are more than one possible abnormity or error, they should be listed in order.

  • Noteif any

    Matters needing attention. If there are more than one matters, they should be listed in order.

  • Examples

    Examples of how to use API.

Format and Examples

API documentation must obey reStructuredText format, please refer to here. Format and examples of each part of API documantation are as follows: (take fc for example)

  • Python API Definition

    • Format

      [Python API Definition]

    • Example

      fc(input,
         size,
         num_flatten_dims=1,
         param_attr=None,
         bias_attr=None,
         act=None,
         name=None,
         main_program=None,
         startup_program=None)
      
  • Function Description

    • Format

      This part contains (please write them in order):

      [Function Description]

      [Formula]

      [Symbols' Descriptions if necessary]

      [References if necessary]

    • Example

      [Function Description]

      **Fully Connected Layer**
      
      The fully connected layer can take multiple tensors as its inputs. It
      creates a variable called weights for each input tensor, which represents
      a fully connected weight matrix from each input unit to each output unit.
      The fully connected layer multiplies each input tensor with its coresponding
      weight to produce an output Tensor. If multiple input tensors are given,
      the results of multiple multiplications will be sumed up. If bias_attr is
      not None, a bias variable will be created and added to the output. Finally,
      if activation is not None, it will be applied to the output as well.
      

      [Formula]

      This process can be formulated as follows:
      
      .. math::
      
           Out = Act({\sum_{i=0}^{N-1}X_iW_i + b})
      

      [Symbols' Descriptions if necessary]

      In the above equation:
      
      * :math:`N`: Number of the input.
      * :math:`X_i`: The input tensor.
      * :math:`W`: The weights created by this layer.
      * :math:`b`: The bias parameter created by this layer (if needed).
      * :math:`Act`: The activation function.
      * :math:`Out`: The output tensor.
      

      [References if necessary]

      Since there is no need for reference of fc, we omit them here. Under other circumstances, please provide explicit reference and link, take layer_norm for example:

      Refer to `Layer Norm