提交 a5200b89 编写于 作者: Y yangyaming

Add doc for max_sequence_len.

上级 6a5cf28a
...@@ -414,9 +414,25 @@ def lod_rank_table(x, level=0): ...@@ -414,9 +414,25 @@ def lod_rank_table(x, level=0):
def max_sequence_len(rank_table): def max_sequence_len(rank_table):
""" """Max Sequence Len Operator. Given a LoDRankTable object, this layer
This function creates an operator to calculate the length of returns the max length of batch of sequences. In fact, a LoDRankTable object
max seqence through input rank_table(should be a lod_rank_table) contains a list of tuples (<sequence index, sequence length>) and the list
is already sorted by sequence length in descending order, so the operator
just returns the sequence length of the first tuple element.
Args:
rank_table (Variable): Input variable which is a LoDRankTable object.
Returns:
Variable: the max length of sequence.
Examples:
.. code-block:: python
x = fluid.layers.data(name='x', shape=[10],
dtype='float32', lod_level=1)
rank_table = layers.lod_rank_table(x=x, level=0)
max_seq_len = layers.max_sequence_len(rank_table)
""" """
helper = LayerHelper("max_seqence_len", **locals()) helper = LayerHelper("max_seqence_len", **locals())
res = helper.create_tmp_variable(dtype="int64") res = helper.create_tmp_variable(dtype="int64")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册