ChunkEvaluator¶

class paddle.fluid.metrics.ChunkEvaluator(name=None)[源代码]

参数¶

• name (str，可选) – 具体用法请参见 Name ，一般无需设置，默认值为None。

ChunkEvaluator

代码示例¶

import paddle.fluid as fluid

# 初始化chunck-level的评价管理。
metric = fluid.metrics.ChunkEvaluator()

# 假设模型预测10个chuncks，其中8个为正确，且真值有9个chuncks。
num_infer_chunks = 10
num_label_chunks = 9
num_correct_chunks = 8

metric.update(num_infer_chunks, num_label_chunks, num_correct_chunks)
numpy_precision, numpy_recall, numpy_f1 = metric.eval()

print("precision: %.2f, recall: %.2f, f1: %.2f" % (numpy_precision, numpy_recall, numpy_f1))

# 下一个batch，完美地预测了3个正确的chuncks。
num_infer_chunks = 3
num_label_chunks = 3
num_correct_chunks = 3

metric.update(num_infer_chunks, num_label_chunks, num_correct_chunks)
numpy_precision, numpy_recall, numpy_f1 = metric.eval()

print("precision: %.2f, recall: %.2f, f1: %.2f" % (numpy_precision, numpy_recall, numpy_f1))


方法¶

update(num_infer_chunks, num_label_chunks, num_correct_chunks)¶

$\begin{split}\\ \begin{array}{l}{\text { self. num_infer_chunks }+=\text { num_infer_chunks }} \\ {\text { self. num_Label_chunks }+=\text { num_label_chunks }} \\ {\text { self. num_correct_chunks }+=\text { num_correct_chunks }}\end{array} \\\end{split}$

• num_infer_chunks (int|numpy.array) – 给定mini-batch的语块数目。
• num_label_chunks (int|numpy.array) - 给定mini-batch的标签中的语块数目。
• num_correct_chunks （int|numpy.array）— 给定mini-batch的正确识别的语块数目。