本文整理汇总了Python中core.config.cfg.EXPECTED_RESULTS属性的典型用法代码示例。如果您正苦于以下问题:Python cfg.EXPECTED_RESULTS属性的具体用法?Python cfg.EXPECTED_RESULTS怎么用?Python cfg.EXPECTED_RESULTS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类core.config.cfg
的用法示例。
在下文中一共展示了cfg.EXPECTED_RESULTS属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_expected_results
# 需要导入模块: from core.config import cfg [as 别名]
# 或者: from core.config.cfg import EXPECTED_RESULTS [as 别名]
def check_expected_results(results, atol=0.005, rtol=0.1):
"""Check actual results against expected results stored in
cfg.EXPECTED_RESULTS. Optionally email if the match exceeds the specified
tolerance.
Expected results should take the form of a list of expectations, each
specified by four elements: [dataset, task, metric, expected value]. For
example: [['coco_2014_minival', 'box_proposal', 'AR@1000', 0.387], ...].
"""
# cfg contains a reference set of results that we want to check against
if len(cfg.EXPECTED_RESULTS) == 0:
return
for dataset, task, metric, expected_val in cfg.EXPECTED_RESULTS:
assert dataset in results, 'Dataset {} not in results'.format(dataset)
assert task in results[dataset], 'Task {} not in results'.format(task)
assert metric in results[dataset][task], \
'Metric {} not in results'.format(metric)
actual_val = results[dataset][task][metric]
err = abs(actual_val - expected_val)
tol = atol + rtol * abs(expected_val)
msg = (
'{} > {} > {} sanity check (actual vs. expected): '
'{:.3f} vs. {:.3f}, err={:.3f}, tol={:.3f}'
).format(dataset, task, metric, actual_val, expected_val, err, tol)
if err > tol:
msg = 'FAIL: ' + msg
logger.error(msg)
if cfg.EXPECTED_RESULTS_EMAIL != '':
subject = 'Detectron end-to-end test failure'
job_name = os.environ[
'DETECTRON_JOB_NAME'
] if 'DETECTRON_JOB_NAME' in os.environ else '<unknown>'
job_id = os.environ[
'WORKFLOW_RUN_ID'
] if 'WORKFLOW_RUN_ID' in os.environ else '<unknown>'
body = [
'Name:',
job_name,
'Run ID:',
job_id,
'Failure:',
msg,
'Config:',
pprint.pformat(cfg),
'Env:',
pprint.pformat(dict(os.environ)),
]
send_email(
subject, '\n\n'.join(body), cfg.EXPECTED_RESULTS_EMAIL
)
else:
msg = 'PASS: ' + msg
logger.info(msg)