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


Python v1.metrics方法代碼示例

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


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

示例1: testDoesNotModifyTF2

# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import metrics [as 別名]
def testDoesNotModifyTF2(self):
    modules_no_overwritten = [
        (tf2.data, tf1.data),
        (tf2.graph_util, tf1.graph_util),
        (tf2.image, tf1.image),
        (tf2.initializers, tf1.initializers),
        (tf2.io, tf1.io),
        (tf2.losses, tf1.losses),
        (tf2.metrics, tf1.metrics),
        (tf2.nn, tf1.nn),
        (tf2.random, tf1.random),
        (tf2.saved_model, tf1.saved_model),
        (tf2.strings, tf1.strings),
        (tf2.summary, tf1.summary),
        (tf2.test, tf1.test),
        (tf2.train, tf1.train),
    ]
    for modules in modules_no_overwritten:
      self.assertIsNot(modules[0], modules[1]) 
開發者ID:tensorflow,項目名稱:lingvo,代碼行數:21,代碼來源:compat_test.py

示例2: reconstruction_loss

# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import metrics [as 別名]
def reconstruction_loss(self, x_input, x_target, x_length, z=None,
                          c_input=None):
    """Reconstruction loss calculation.

    Args:
      x_input: Batch of decoder input sequences for teacher forcing, sized
          `[batch_size, max(x_length), output_depth]`.
      x_target: Batch of expected output sequences to compute loss against,
          sized `[batch_size, max(x_length), output_depth]`.
      x_length: Length of input/output sequences, sized `[batch_size]`.
      z: (Optional) Latent vectors. Required if model is conditional. Sized
          `[n, z_size]`.
      c_input: (Optional) Batch of control sequences, sized
          `[batch_size, max(x_length), control_depth]`. Required if conditioning
          on control sequences.

    Returns:
      r_loss: The reconstruction loss for each sequence in the batch.
      metric_map: Map from metric name to tf.metrics return values for logging.
    """
    pass 
開發者ID:magenta,項目名稱:magenta,代碼行數:23,代碼來源:base_model.py

示例3: hamming_loss

# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import metrics [as 別名]
def hamming_loss(preds, targets, sign=False):
  """Implements hamming loss.

  Args:
    preds: Tensor of predicted values.
    targets: Tensor of target values.
    sign (bool): Set to True if targets={-1, 1} to take the sign of preds
    before calculating loss.

  Returns:
    A tf.metrics tuple containing the proportion of incorrect predictions and an
    update op for the metric.
  """
  if sign:
    preds = tf.sign(preds)
  equal = tf.equal(preds, tf.cast(targets, preds.dtype))
  proportion_correct, update_op = tf.metrics.mean(tf.cast(equal, tf.float32))
  return 1 - proportion_correct, update_op 
開發者ID:google-research,項目名稱:language,代碼行數:20,代碼來源:model_utils.py

示例4: eval

# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import metrics [as 別名]
def eval(self, input_sequence, output_sequence, sequence_length,
           control_sequence=None):
    """Evaluate on the given sequences, returning metric update ops.

    Args:
      input_sequence: The sequence to be fed to the encoder.
      output_sequence: The sequence expected from the decoder.
      sequence_length: The length of the given sequences (which must be
        identical).
      control_sequence: (Optional) sequence on which to condition the decoder.

    Returns:
      metric_update_ops: tf.metrics update ops.
    """
    metric_map, scalars_to_summarize = self._compute_model_loss(
        input_sequence, output_sequence, sequence_length, control_sequence)

    for n, t in scalars_to_summarize.items():
      metric_map[n] = tf.metrics.mean(t)

    metrics_to_values, metrics_to_updates = (
        tf_slim.metrics.aggregate_metric_map(metric_map))

    for metric_name, metric_value in metrics_to_values.items():
      tf.summary.scalar(metric_name, metric_value)

    return list(metrics_to_updates.values()) 
開發者ID:magenta,項目名稱:magenta,代碼行數:29,代碼來源:base_model.py

示例5: _flat_reconstruction_loss

# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import metrics [as 別名]
def _flat_reconstruction_loss(self, flat_x_target, flat_rnn_output):
    """Core loss calculation method for flattened outputs.

    Args:
      flat_x_target: The flattened ground truth vectors, sized
        `[sum(x_length), self._output_depth]`.
      flat_rnn_output: The flattened output from all timeputs of the RNN,
        sized `[sum(x_length), rnn_output_size]`.
    Returns:
      r_loss: The unreduced reconstruction losses, sized `[sum(x_length)]`.
      metric_map: A map of metric names to tuples, each of which contain the
        pair of (value_tensor, update_op) from a tf.metrics streaming metric.
    """
    pass 
開發者ID:magenta,項目名稱:magenta,代碼行數:16,代碼來源:lstm_models.py


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