From 0978bca47eefa827f4dc77fd6b963c8d6022889b Mon Sep 17 00:00:00 2001 From: liu zhengxi <380185688@qq.com> Date: Mon, 19 Dec 2022 11:32:55 +0800 Subject: [PATCH] Refine dynamic_decode docs (#49151) --- python/paddle/nn/decode.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/python/paddle/nn/decode.py b/python/paddle/nn/decode.py index c2e652b63d8..4ad72077014 100644 --- a/python/paddle/nn/decode.py +++ b/python/paddle/nn/decode.py @@ -1029,26 +1029,22 @@ def dynamic_decode( **kwargs: Additional keyword arguments. Arguments passed to `decoder.step`. Returns: - tuple: A tuple( :code:`(final_outputs, final_states, sequence_lengths)` ) \ - when `return_length` is True, otherwise a tuple( :code:`(final_outputs, final_states)` ). \ - The final outputs and states, both are Tensor or nested structure of Tensor. \ - `final_outputs` has the same structure and data types as the :code:`outputs` \ - returned by :code:`decoder.step()` , and each Tenser in `final_outputs` \ - is the stacked of all decoding steps' outputs, which might be revised \ - by :code:`decoder.finalize()` if the decoder has implemented `finalize`. \ - `final_states` is the counterpart at last time step of initial states \ - returned by :code:`decoder.initialize()` , thus has the same structure \ - with it and has tensors with same shapes and data types. `sequence_lengths` \ - is an `int64` tensor with the same shape as `finished` returned \ - by :code:`decoder.initialize()` , and it stores the actual lengths of \ - all decoded sequences. + + - final_outputs (Tensor, nested structure of Tensor), each Tensor in :code:`final_outputs` is the stacked of all decoding steps' outputs, which might be revised + by :code:`decoder.finalize()` if the decoder has implemented finalize. + And :code:`final_outputs` has the same structure and data types as the :code:`outputs` + returned by :code:`decoder.step()` + - final_states (Tensor, nested structure of Tensor), :code:`final_states` is the counterpart at last time step of initial states \ + returned by :code:`decoder.initialize()` , thus has the same structure + with it and has tensors with same shapes and data types. + - sequence_lengths (Tensor), stores the actual lengths of all decoded sequences. + sequence_lengths is provided only if :code:`return_length` is True. Examples: .. code-block:: python - import numpy as np import paddle from paddle.nn import BeamSearchDecoder, dynamic_decode from paddle.nn import GRUCell, Linear, Embedding -- GitLab