Skip to content

Commit

Permalink
Add an extra parameter label to chunk_evaluator
Browse files Browse the repository at this point in the history
In order to keep consistent with other evaluators, an extra parameter
label is add to chunk_evaluator. Document and demos are modified
accordingly.
  • Loading branch information
Peng Li committed Dec 15, 2016
1 parent 18fabf6 commit c287b6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion demo/sequence_tagging/linear_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def get_simd_size(size):

chunk_evaluator(
name="chunk_f1",
input=[crf_decoding, chunk],
input=crf_decoding,
label=chunk,
chunk_scheme="IOB",
num_chunk_types=11, )

Expand Down
3 changes: 2 additions & 1 deletion demo/sequence_tagging/rnn_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@

chunk_evaluator(
name="chunk_f1",
input=[crf_decoding, chunk],
input=crf_decoding,
label=chunk,
chunk_scheme="IOB",
num_chunk_types=11, )

Expand Down
18 changes: 11 additions & 7 deletions python/paddle/trainer_config_helpers/evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,11 @@ def ctc_error_evaluator(
@wrap_name_default()
def chunk_evaluator(
input,
label,
chunk_scheme,
num_chunk_types,
name=None,
chunk_scheme=None,
num_chunk_types=None, ):
):
"""
Chunk evaluator is used to evaluate segment labelling accuracy for a
sequence. It calculates the chunk detection F1 score.
Expand Down Expand Up @@ -363,22 +365,24 @@ def chunk_evaluator(
.. code-block:: python
eval = chunk_evaluator(input)
eval = chunk_evaluator(input, label, chunk_scheme, num_chunk_types)
:param input: The input layers.
:type input: LayerOutput
:param name: The Evaluator name, it is not necessary.
:type name: basename|None
:param label: An input layer containing the ground truth label.
:type label: LayerOutput
:param chunk_scheme: The labelling schemes support 4 types. It is one of
"IOB", "IOE", "IOBES", "plain".This Evaluator must
contain this chunk_scheme.
"IOB", "IOE", "IOBES", "plain". It is required.
:type chunk_scheme: basestring
:param num_chunk_types: number of chunk types other than "other"
:param name: The Evaluator name, it is optional.
:type name: basename|None
"""
evaluator_base(
name=name,
type="chunk",
input=input,
label=label,
chunk_scheme=chunk_scheme,
num_chunk_types=num_chunk_types)

Expand Down

0 comments on commit c287b6b

Please sign in to comment.