@@ -834,11 +834,14 @@ def linear_chain_crf(input, label, param_attr=None):
834
834
835
835
Args:
836
836
input(${emission_type}): ${emission_comment}
837
+ input(${transition_type}): ${transition_comment}
837
838
label(${label_type}): ${label_comment}
838
839
param_attr(ParamAttr): The attribute of the learnable parameter.
839
840
840
841
Returns:
841
842
${log_likelihood_comment}
843
+ ${transitionexps_comment}
844
+ ${emissionexps_comment}
842
845
843
846
"""
844
847
helper = LayerHelper ('linear_chain_crf' , ** locals ())
@@ -1170,10 +1173,6 @@ def sequence_conv(input,
1170
1173
Variable: output of sequence_conv
1171
1174
"""
1172
1175
1173
- # FIXME(dzh) : want to unify the argument of python layer
1174
- # function. So we ignore some unecessary attributes.
1175
- # such as, padding_trainable, context_start.
1176
-
1177
1176
helper = LayerHelper ('sequence_conv' , ** locals ())
1178
1177
dtype = helper .input_dtype ()
1179
1178
filter_shape = [filter_size * input .shape [1 ], num_filters ]
@@ -2051,18 +2050,31 @@ def layer_norm(input,
2051
2050
2052
2051
def beam_search_decode (ids , scores , name = None ):
2053
2052
"""
2053
+ Beam Search Decode
2054
+
2054
2055
This layers is to pack the output of beam search layer into sentences and
2055
2056
associated scores. It is usually called after the beam search layer.
2057
+ Typically, the output of beam search layer is a tensor of selected ids, with
2058
+ a tensor of the score of each id. Beam search layer's output ids, however,
2059
+ are generated directly during the tree search, and they are stacked by each
2060
+ level of the search tree. Thus we need to reorganize them into sentences,
2061
+ based on the score of each id. This layer takes the output of beam search
2062
+ layer as input and repack them into sentences.
2056
2063
2057
2064
${beam_search_decode}
2058
2065
2059
2066
Args:
2060
- ids (Variable): ${ids_comment}
2061
- scores (Variable): ${scores_comment}
2067
+ ids (Variable): The selected ids, output of beam search layer.
2068
+ scores (Variable): The associated scores of the ids, out put of beam
2069
+ search layer.
2062
2070
name (str): The name of this layer. It is optional.
2063
2071
2064
2072
Returns:
2065
- tuple(Variable): a tuple of two output variable: sentence_ids, sentence_scores
2073
+ tuple(Variable): a tuple of two output tensors: sentence_ids, sentence_scores.
2074
+ sentence_ids is a tensor with shape [size, length], where size is the
2075
+ beam size of beam search, and length is the length of each sentence.
2076
+ Note that the length of sentences may vary.
2077
+ sentence_scores is a tensor with the same shape as sentence_ids.
2066
2078
2067
2079
Examples:
2068
2080
.. code-block:: python
0 commit comments