执行测试过程 Args: exe: 执行空间,即CPU和GPU program: 用于测试用的program reader: PyReader类型,读取数据 Returns:
(exe, program, reader, test_ret)
| 244 | |
| 245 | |
| 246 | def test_process(exe, program, reader, test_ret): |
| 247 | """执行测试过程 |
| 248 | |
| 249 | Args: |
| 250 | exe: 执行空间,即CPU和GPU |
| 251 | program: 用于测试用的program |
| 252 | reader: PyReader类型,读取数据 |
| 253 | |
| 254 | Returns: |
| 255 | |
| 256 | """ |
| 257 | test_ret["chunk_evaluator"].reset() |
| 258 | for data in reader(): |
| 259 | nums_infer, nums_label, nums_correct = exe.run( |
| 260 | program, |
| 261 | fetch_list=[ |
| 262 | test_ret["num_infer_chunks"], |
| 263 | test_ret["num_label_chunks"], |
| 264 | test_ret["num_correct_chunks"], |
| 265 | ], |
| 266 | feed=data, |
| 267 | ) |
| 268 | |
| 269 | test_ret["chunk_evaluator"].update( |
| 270 | nums_infer, nums_label, nums_correct) |
| 271 | precision, recall, f1 = test_ret["chunk_evaluator"].eval() |
| 272 | print("[test] P: %.5f, R: %.5f, F1: %.5f" |
| 273 | % (precision, recall, f1)) |
| 274 | |
| 275 | |
| 276 | def do_train(args, dataset, segment_tool): |