Skip to content

Commit

Permalink
refine bsd doc (#48882)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostML authored Dec 8, 2022
1 parent 93acef3 commit 8c41665
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions python/paddle/nn/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

class Decoder:
"""
:api_attr: Static Graph
Decoder is the base class for any decoder instance used in `dynamic_decode`.
It provides interface for output generation for one time step, which can be
used to generate sequences.
Expand Down Expand Up @@ -146,13 +144,14 @@ class BeamSearchDecoder(Decoder):
Please refer to `Beam search <https://en.wikipedia.org/wiki/Beam_search>`_
for more details.
**NOTE** When decoding with beam search, the `inputs` and `states` of cell
would be tiled to `beam_size` (unsqueeze and tile), resulting to shapes like
`[batch_size * beam_size, ...]` , which is built into `BeamSearchDecoder` and
done automatically. Thus any other tensor with shape `[batch_size, ...]` used
in `cell.call` needs to be tiled manually first, which can be completed by using
:code:`BeamSearchDecoder.tile_beam_merge_with_batch` . The most common case
for this is the encoder output in attention mechanism.
Note:
When decoding with beam search, the `inputs` and `states` of cell
would be tiled to `beam_size` (unsqueeze and tile), resulting to shapes like
`[batch_size * beam_size, ...]` , which is built into `BeamSearchDecoder` and
done automatically. Thus any other tensor with shape `[batch_size, ...]` used
in `cell.call` needs to be tiled manually first, which can be completed by using
:code:`BeamSearchDecoder.tile_beam_merge_with_batch` . The most common case
for this is the encoder output in attention mechanism.
Returns:
BeamSearchDecoder: An instance of decoder which can be used in \
Expand Down

0 comments on commit 8c41665

Please sign in to comment.