Skip to content

Commit c287b6b

Browse files
author
Peng Li
committed
Add an extra parameter label to chunk_evaluator
In order to keep consistent with other evaluators, an extra parameter label is add to chunk_evaluator. Document and demos are modified accordingly.
1 parent 18fabf6 commit c287b6b

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

demo/sequence_tagging/linear_crf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def get_simd_size(size):
7474

7575
chunk_evaluator(
7676
name="chunk_f1",
77-
input=[crf_decoding, chunk],
77+
input=crf_decoding,
78+
label=chunk,
7879
chunk_scheme="IOB",
7980
num_chunk_types=11, )
8081

demo/sequence_tagging/rnn_crf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@
112112

113113
chunk_evaluator(
114114
name="chunk_f1",
115-
input=[crf_decoding, chunk],
115+
input=crf_decoding,
116+
label=chunk,
116117
chunk_scheme="IOB",
117118
num_chunk_types=11, )
118119

python/paddle/trainer_config_helpers/evaluators.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,11 @@ def ctc_error_evaluator(
327327
@wrap_name_default()
328328
def chunk_evaluator(
329329
input,
330+
label,
331+
chunk_scheme,
332+
num_chunk_types,
330333
name=None,
331-
chunk_scheme=None,
332-
num_chunk_types=None, ):
334+
):
333335
"""
334336
Chunk evaluator is used to evaluate segment labelling accuracy for a
335337
sequence. It calculates the chunk detection F1 score.
@@ -363,22 +365,24 @@ def chunk_evaluator(
363365
364366
.. code-block:: python
365367
366-
eval = chunk_evaluator(input)
368+
eval = chunk_evaluator(input, label, chunk_scheme, num_chunk_types)
367369
368370
:param input: The input layers.
369371
:type input: LayerOutput
370-
:param name: The Evaluator name, it is not necessary.
371-
:type name: basename|None
372+
:param label: An input layer containing the ground truth label.
373+
:type label: LayerOutput
372374
:param chunk_scheme: The labelling schemes support 4 types. It is one of
373-
"IOB", "IOE", "IOBES", "plain".This Evaluator must
374-
contain this chunk_scheme.
375+
"IOB", "IOE", "IOBES", "plain". It is required.
375376
:type chunk_scheme: basestring
376377
:param num_chunk_types: number of chunk types other than "other"
378+
:param name: The Evaluator name, it is optional.
379+
:type name: basename|None
377380
"""
378381
evaluator_base(
379382
name=name,
380383
type="chunk",
381384
input=input,
385+
label=label,
382386
chunk_scheme=chunk_scheme,
383387
num_chunk_types=num_chunk_types)
384388

0 commit comments

Comments
 (0)