當前位置: 首頁>>代碼示例>>Python>>正文


Python metrics.streaming_mean方法代碼示例

本文整理匯總了Python中tensorflow.contrib.metrics.streaming_mean方法的典型用法代碼示例。如果您正苦於以下問題:Python metrics.streaming_mean方法的具體用法?Python metrics.streaming_mean怎麽用?Python metrics.streaming_mean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.metrics的用法示例。


在下文中一共展示了metrics.streaming_mean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_eval_ops

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _get_eval_ops(self, features, labels, metrics):
    """Method that builds model graph and returns evaluation ops.

    Expected to be overriden by sub-classes that require custom support.
    This implementation uses `model_fn` passed as parameter to constructor to
    build model.

    Args:
      features: `Tensor` or `dict` of `Tensor` objects.
      labels: `Tensor` or `dict` of `Tensor` objects.
      metrics: Dict of metrics to run. If None, the default metric functions
        are used; if {}, no metrics are used. Otherwise, `metrics` should map
        friendly names for the metric to a `MetricSpec` object defining which
        model outputs to evaluate against which labels with which metric
        function. Metric ops should support streaming, e.g., returning
        update_op and value tensors. See more details in
        `../../../../metrics/python/metrics/ops/streaming_metrics.py` and
        `../metric_spec.py`.

    Returns:
      `ModelFnOps` object.

    Raises:
      ValueError: if `metrics` don't match `labels`.
    """
    model_fn_ops = self._call_model_fn(
        features, labels, model_fn_lib.ModeKeys.EVAL)

    features, labels = self._feature_engineering_fn(features, labels)
    # Custom metrics should overwrite defaults.
    if metrics:
      model_fn_ops.eval_metric_ops.update(_make_metrics_ops(
          metrics, features, labels, model_fn_ops.predictions))

    if metric_key.MetricKey.LOSS not in model_fn_ops.eval_metric_ops:
      model_fn_ops.eval_metric_ops[metric_key.MetricKey.LOSS] = (
          metrics_lib.streaming_mean(model_fn_ops.loss))
    return model_fn_ops 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:40,代碼來源:estimator.py

示例2: _metrics

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _metrics(self, eval_loss, predictions, labels, weights):
    """Returns a dict of metrics keyed by name."""
    del predictions, labels, weights  # Unused by this head.
    with ops.name_scope("metrics", values=[eval_loss]):
      return {
          _summary_key(self.head_name, mkey.LOSS):
              metrics_lib.streaming_mean(eval_loss)} 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:head.py

示例3: _indicator_labels_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _indicator_labels_streaming_mean(labels, weights=None, class_id=None):
  labels = math_ops.to_float(labels)
  weights = _float_weights_or_none(weights)
  if weights is not None:
    weights = weights_broadcast_ops.broadcast_weights(weights, labels)
  if class_id is not None:
    if weights is not None:
      weights = weights[:, class_id]
    labels = labels[:, class_id]
  return metrics_lib.streaming_mean(labels, weights=weights) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:12,代碼來源:head.py

示例4: _predictions_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _predictions_streaming_mean(predictions,
                                weights=None,
                                class_id=None):
  predictions = math_ops.to_float(predictions)
  weights = _float_weights_or_none(weights)
  if weights is not None:
    weights = weights_broadcast_ops.broadcast_weights(weights, predictions)
  if class_id is not None:
    if weights is not None:
      weights = weights[:, class_id]
    predictions = predictions[:, class_id]
  return metrics_lib.streaming_mean(predictions, weights=weights)


# TODO(ptucker): Add support for SparseTensor labels. 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:17,代碼來源:head.py

示例5: _class_predictions_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _class_predictions_streaming_mean(predictions, weights, class_id):
  return metrics_lib.streaming_mean(
      array_ops.where(
          math_ops.equal(
              math_ops.to_int32(class_id), math_ops.to_int32(predictions)),
          array_ops.ones_like(predictions),
          array_ops.zeros_like(predictions)),
      weights=weights) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:10,代碼來源:head.py

示例6: _class_labels_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _class_labels_streaming_mean(labels, weights, class_id):
  return metrics_lib.streaming_mean(
      array_ops.where(
          math_ops.equal(
              math_ops.to_int32(class_id), math_ops.to_int32(labels)),
          array_ops.ones_like(labels), array_ops.zeros_like(labels)),
      weights=weights) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:head.py

示例7: _get_eval_ops

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _get_eval_ops(self, features, labels, metrics):
    """Method that builds model graph and returns evaluation ops.

    Expected to be overriden by sub-classes that require custom support.
    This implementation uses `model_fn` passed as parameter to constructor to
    build model.

    Args:
      features: `Tensor` or `dict` of `Tensor` objects.
      labels: `Tensor` or `dict` of `Tensor` objects.
      metrics: Dict of metrics to run. If None, the default metric functions
        are used; if {}, no metrics are used. Otherwise, `metrics` should map
        friendly names for the metric to a `MetricSpec` object defining which
        model outputs to evaluate against which labels with which metric
        function. Metric ops should support streaming, e.g., returning
        update_op and value tensors. See more details in
        `../../../../metrics/python/metrics/ops/streaming_metrics.py` and
        `../metric_spec.py`.

    Returns:
      `ModelFnOps` object.

    Raises:
      ValueError: if `metrics` don't match `labels`.
    """
    model_fn_ops = self._call_model_fn(
        features, labels, model_fn_lib.ModeKeys.EVAL)

    # Custom metrics should overwrite defaults.
    if metrics:
      model_fn_ops.eval_metric_ops.update(_make_metrics_ops(
          metrics, features, labels, model_fn_ops.predictions))

    if metric_key.MetricKey.LOSS not in model_fn_ops.eval_metric_ops:
      model_fn_ops.eval_metric_ops[metric_key.MetricKey.LOSS] = (
          metrics_lib.streaming_mean(model_fn_ops.loss))
    return model_fn_ops 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:39,代碼來源:estimator.py

示例8: _weighted_average_loss_metric_spec

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _weighted_average_loss_metric_spec(loss_fn, pred_key, label_key,
                                       weight_key):

  def _streaming_weighted_average_loss(predictions, labels, weights=None):
    loss_unweighted = loss_fn(predictions, labels)
    if weights is not None:
      weights = math_ops.to_float(weights)
    _, weighted_average_loss = _loss(loss_unweighted, weights, name="eval_loss")
    return metrics_lib.streaming_mean(weighted_average_loss)

  return metric_spec.MetricSpec(_streaming_weighted_average_loss, pred_key,
                                label_key, weight_key) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:14,代碼來源:head.py

示例9: _indicator_labels_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _indicator_labels_streaming_mean(predictions,
                                     labels,
                                     weights=None,
                                     class_id=None):
  del predictions
  if class_id is not None:
    labels = labels[:, class_id]
  return metrics_lib.streaming_mean(labels, weights=weights) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:10,代碼來源:head.py

示例10: _predictions_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _predictions_streaming_mean(predictions,
                                labels,
                                weights=None,
                                class_id=None):
  del labels
  if class_id is not None:
    predictions = predictions[:, class_id]
  return metrics_lib.streaming_mean(predictions, weights=weights)


# TODO(ptucker): Add support for SparseTensor labels. 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:13,代碼來源:head.py

示例11: _get_eval_ops

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _get_eval_ops(self, features, labels, metrics):
    """Method that builds model graph and returns evaluation ops.

    Expected to be overriden by sub-classes that require custom support.
    This implementation uses `model_fn` passed as parameter to constructor to
    build model.

    Args:
      features: `Tensor` or `dict` of `Tensor` objects.
      labels: `Tensor` or `dict` of `Tensor` objects.
      metrics: Dict of metrics to run. If None, the default metric functions
        are used; if {}, no metrics are used. Otherwise, `metrics` should map
        friendly names for the metric to a `MetricSpec` object defining which
        model outputs to evaluate against which labels with which metric
        function. Metric ops should support streaming, e.g., returning
        update_op and value tensors. See more details in
        `../../../../metrics/python/metrics/ops/streaming_metrics.py` and
        `../metric_spec.py`.

    Returns:
      metrics: `dict` of `Tensor` objects.

    Raises:
      ValueError: if `metrics` don't match `labels`.
    """
    model_fn_ops = self._call_model_fn(features, labels, ModeKeys.EVAL)

    all_metrics = model_fn_ops.default_metrics
    # Custom metrics should overwrite defaults.
    if metrics:
      all_metrics.update(metrics)

    result = _make_metrics_ops(all_metrics, features, labels,
                               model_fn_ops.predictions)
    if metric_key.MetricKey.LOSS not in result:
      result[metric_key.MetricKey.LOSS] = metrics_lib.streaming_mean(
          model_fn_ops.loss)
    return result 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:40,代碼來源:estimator.py

示例12: _weighted_average_loss_metric_spec

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _weighted_average_loss_metric_spec(loss_fn, predictoin_key,
                                       label_key, weight_key):
  def _streaming_weighted_average_loss(predictions, labels, weights=None):
    loss_unweighted = loss_fn(predictions, labels)
    if weights is not None:
      weights = math_ops.to_float(weights)
    _, weighted_average_loss = _loss(loss_unweighted,
                                     weights,
                                     name="eval_loss")
    return metrics_lib.streaming_mean(weighted_average_loss)
  return metric_spec.MetricSpec(_streaming_weighted_average_loss,
                                predictoin_key, label_key, weight_key) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:head.py

示例13: _labels_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _labels_streaming_mean(unused_predictions, labels, weights=None):
  return metrics_lib.streaming_mean(labels, weights=weights) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:head.py

示例14: _predictions_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _predictions_streaming_mean(predictions, unused_labels, weights=None):
  return metrics_lib.streaming_mean(predictions, weights=weights) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:head.py

示例15: _labels_streaming_mean

# 需要導入模塊: from tensorflow.contrib import metrics [as 別名]
# 或者: from tensorflow.contrib.metrics import streaming_mean [as 別名]
def _labels_streaming_mean(unused_predictions, labels):
  return metrics_lib.streaming_mean(labels) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:logistic_regressor.py


注:本文中的tensorflow.contrib.metrics.streaming_mean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。