当前位置: 首页>>代码示例>>Python>>正文


Python chainer.Reporter方法代码示例

本文整理汇总了Python中chainer.Reporter方法的典型用法代码示例。如果您正苦于以下问题:Python chainer.Reporter方法的具体用法?Python chainer.Reporter怎么用?Python chainer.Reporter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainer的用法示例。


在下文中一共展示了chainer.Reporter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_evaluate

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_evaluate(self):
        reporter = chainer.Reporter()
        reporter.add_observer('target', self.link)
        with reporter:
            mean = self.evaluator.evaluate()

        # No observation is reported to the current reporter. Instead the
        # evaluator collect results in order to calculate their mean.
        self.assertEqual(len(reporter.observation), 0)

        key = 'ap/iou=0.50:0.95/area=all/max_dets=100'
        np.testing.assert_equal(
            mean['target/m{}'.format(key)], self.expected_ap)
        np.testing.assert_equal(mean['target/{}/cls0'.format(key)], np.nan)
        np.testing.assert_equal(mean['target/{}/cls1'.format(key)], np.nan)
        np.testing.assert_equal(
            mean['target/{}/cls2'.format(key)], self.expected_ap) 
开发者ID:chainer,项目名称:chainercv,代码行数:19,代码来源:test_detection_coco_evaluator.py

示例2: test_evaluate

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_evaluate(self):
        reporter = chainer.Reporter()
        reporter.add_observer('main', self.link)
        with reporter:
            eval_ = self.evaluator.evaluate()

        # No observation is reported to the current reporter. Instead the
        # evaluator collect results in order to calculate their mean.
        np.testing.assert_equal(len(reporter.observation), 0)

        np.testing.assert_equal(eval_['main/miou'], self.miou)
        np.testing.assert_equal(eval_['main/pixel_accuracy'],
                                self.pixel_accuracy)
        np.testing.assert_equal(eval_['main/mean_class_accuracy'],
                                self.mean_class_accuracy)
        np.testing.assert_equal(eval_['main/iou/a'], self.iou_a)
        np.testing.assert_equal(eval_['main/iou/b'], self.iou_b)
        np.testing.assert_equal(eval_['main/iou/c'], np.nan)
        np.testing.assert_equal(eval_['main/class_accuracy/a'],
                                self.class_accuracy_a)
        np.testing.assert_equal(eval_['main/class_accuracy/b'],
                                self.class_accuracy_b)
        np.testing.assert_equal(eval_['main/class_accuracy/c'], np.nan) 
开发者ID:chainer,项目名称:chainercv,代码行数:25,代码来源:test_semantic_segmentation_evaluator.py

示例3: test_evaluate

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_evaluate(self):
        reporter = chainer.Reporter()
        reporter.add_observer('target', self.link)
        with reporter:
            mean = self.evaluator.evaluate()

        # No observation is reported to the current reporter. Instead the
        # evaluator collect results in order to calculate their mean.
        self.assertEqual(len(reporter.observation), 0)

        key = 'ap/iou=0.50:0.95/area=all/max_dets=100'
        np.testing.assert_equal(
            mean['target/m{}'.format(key)], self.expected_ap)
        np.testing.assert_equal(mean['target/{}/cls0'.format(key)], np.nan)
        np.testing.assert_equal(
            mean['target/{}/cls1'.format(key)], self.expected_ap)
        np.testing.assert_equal(mean['target/{}/cls2'.format(key)], np.nan) 
开发者ID:chainer,项目名称:chainercv,代码行数:19,代码来源:test_instance_segmentation_coco_evaluator.py

示例4: _test_r2_score_evaluator

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_r2_score_evaluator(inputs):
    predictor = DummyPredictor()
    x0, x1, _ = inputs
    dataset = NumpyTupleDataset(x0, x1)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = R2ScoreEvaluator(iterator, predictor, name='train')
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected = r2_score(x0, x1)
    pytest.approx(observation['target/r2_score'], expected)

    # --- test __call__ ---
    result = evaluator()
    pytest.approx(result['train/main/r2_score'], expected) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:20,代码来源:test_r2_score_evaluator.py

示例5: _test_r2_score_evaluator_ignore_nan

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_r2_score_evaluator_ignore_nan(inputs):
    predictor = DummyPredictor()
    x0, _, x2 = inputs
    dataset = NumpyTupleDataset(x0, x2)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = R2ScoreEvaluator(
        iterator, predictor, name='train', ignore_nan=True)
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected = r2_score(x0, x2, ignore_nan=True)
    pytest.approx(observation['target/r2_score'], expected)

    # --- test __call__ ---
    result = evaluator()
    pytest.approx(result['train/main/r2_score'], expected) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:21,代码来源:test_r2_score_evaluator.py

示例6: _test_r2_score_evaluator_ignore_nan_with_nonnan_value

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_r2_score_evaluator_ignore_nan_with_nonnan_value(inputs):
    predictor = DummyPredictor()
    x0, x1, _ = inputs
    dataset = NumpyTupleDataset(x0, x1)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = R2ScoreEvaluator(
        iterator, predictor, name='train', ignore_nan=True)
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected = r2_score(x0, x1, ignore_nan=True)
    pytest.approx(observation['target/r2_score'], expected)

    # --- test __call__ ---
    result = evaluator()
    pytest.approx(result['train/main/r2_score'], expected) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:21,代码来源:test_r2_score_evaluator.py

示例7: _test_r2_score_evaluator_raw_values

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_r2_score_evaluator_raw_values(inputs):
    predictor = DummyPredictor()
    x0, x1, _ = inputs
    dataset = NumpyTupleDataset(x0, x1)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = R2ScoreEvaluator(
        iterator, predictor, name='train', multioutput='raw_values')
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected = r2_score(x0, x1, multioutput='raw_values')
    pytest.approx(observation['target/r2_score'], expected)

    # --- test __call__ ---
    result = evaluator()
    pytest.approx(result['train/main/r2_score'], expected) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:21,代码来源:test_r2_score_evaluator.py

示例8: _test_prc_auc_evaluator_default_args

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_prc_auc_evaluator_default_args(data0):

    predictor = DummyPredictor()
    dataset = NumpyTupleDataset(*data0)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = PRCAUCEvaluator(
        iterator, predictor, name='train',
        pos_labels=1, ignore_labels=None
    )
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected_prc_auc = 0.7916
    pytest.approx(observation['target/prc_auc'], expected_prc_auc)

    # --- test __call__ ---
    result = evaluator()
    pytest.approx(result['train/main/prc_auc'], expected_prc_auc) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:23,代码来源:test_prc_auc_evaluator.py

示例9: _test_prc_auc_evaluator_raise_error

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_prc_auc_evaluator_raise_error(data, raise_value_error=True):

    predictor = DummyPredictor()
    dataset = NumpyTupleDataset(*data)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = PRCAUCEvaluator(
        iterator, predictor, name='train',
        pos_labels=1, ignore_labels=None,
        raise_value_error=raise_value_error
    )
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    return observation['target/prc_auc'] 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:19,代码来源:test_prc_auc_evaluator.py

示例10: _test_roc_auc_evaluator_default_args

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_roc_auc_evaluator_default_args(data0):

    predictor = DummyPredictor()
    dataset = NumpyTupleDataset(*data0)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = ROCAUCEvaluator(
        iterator, predictor, name='train',
        pos_labels=1, ignore_labels=None
    )
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    expected_roc_auc = 0.75
    # print('observation ', observation)
    assert observation['target/roc_auc'] == expected_roc_auc

    # --- test __call__ ---
    result = evaluator()
    # print('result ', result)
    assert result['train/main/roc_auc'] == expected_roc_auc 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:25,代码来源:test_roc_auc_evaluator.py

示例11: _test_roc_auc_evaluator_raise_error

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def _test_roc_auc_evaluator_raise_error(data, raise_value_error=True):

    predictor = DummyPredictor()
    dataset = NumpyTupleDataset(*data)

    iterator = SerialIterator(dataset, 2, repeat=False, shuffle=False)
    evaluator = ROCAUCEvaluator(
        iterator, predictor, name='train',
        pos_labels=1, ignore_labels=None,
        raise_value_error=raise_value_error
    )
    repo = chainer.Reporter()
    repo.add_observer('target', predictor)
    with repo:
        observation = evaluator.evaluate()

    return observation['target/roc_auc'] 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:19,代码来源:test_roc_auc_evaluator.py

示例12: test_report_key

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_report_key(self, metrics_fun, compute_metrics):
        repo = chainer.Reporter()

        link = Regressor(predictor=DummyPredictor(),
                         metrics_fun=metrics_fun)
        link.compute_metrics = compute_metrics
        repo.add_observer('target', link)
        with repo:
            observation = {}
            with reporter.report_scope(observation):
                link(self.x, self.t)

        # print('observation ', observation)
        actual_keys = set(observation.keys())
        if compute_metrics:
            if metrics_fun is None:
                assert set(['target/loss']) == actual_keys
            elif isinstance(metrics_fun, dict):
                assert set(['target/loss', 'target/user_key']) == actual_keys
            elif callable(metrics_fun):
                assert set(['target/loss', 'target/metrics']) == actual_keys
            else:
                raise TypeError()
        else:
            assert set(['target/loss']) == actual_keys 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:27,代码来源:test_regressor.py

示例13: test_empty_reporter

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_empty_reporter(self):
        reporter = chainer.Reporter()
        self.assertEqual(reporter.observation, {}) 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_reporter.py

示例14: test_enter_exit

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_enter_exit(self):
        reporter1 = chainer.Reporter()
        reporter2 = chainer.Reporter()
        with reporter1:
            self.assertIs(chainer.get_current_reporter(), reporter1)
            with reporter2:
                self.assertIs(chainer.get_current_reporter(), reporter2)
            self.assertIs(chainer.get_current_reporter(), reporter1) 
开发者ID:chainer,项目名称:chainer,代码行数:10,代码来源:test_reporter.py

示例15: test_enter_exit_threadsafe

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import Reporter [as 别名]
def test_enter_exit_threadsafe(self):
        # This test ensures reporter.__enter__ correctly stores the reporter
        # in the thread-local storage.

        def thread_func(reporter, record):
            with reporter:
                # Sleep for a tiny moment to cause an overlap of the context
                # managers.
                time.sleep(0.01)
                record.append(chainer.get_current_reporter())

        record1 = []  # The current repoter in each thread is stored here.
        record2 = []
        reporter1 = chainer.Reporter()
        reporter2 = chainer.Reporter()
        thread1 = threading.Thread(
            target=thread_func,
            args=(reporter1, record1))
        thread2 = threading.Thread(
            target=thread_func,
            args=(reporter2, record2))
        thread1.daemon = True
        thread2.daemon = True
        thread1.start()
        thread2.start()
        thread1.join()
        thread2.join()
        self.assertIs(record1[0], reporter1)
        self.assertIs(record2[0], reporter2) 
开发者ID:chainer,项目名称:chainer,代码行数:31,代码来源:test_reporter.py


注:本文中的chainer.Reporter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。