MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / call

Method call

tensorflow/contrib/eager/python/metrics_impl.py:520–547  ·  view source on GitHub ↗

Accumulate accuracy statistics. `labels` and `predictions` should have the same shape except the predictions must have one additional trailing dimension equal to the number of classes(you want to predict). Type of labels and predictions can be different. Args: labels: Te

(self, labels, predictions, weights=None)

Source from the content-addressed store, hash-verified

518 super(SparseAccuracy, self).__init__(name=name, dtype=dtype)
519
520 def call(self, labels, predictions, weights=None):
521 """Accumulate accuracy statistics.
522
523 `labels` and `predictions` should have the same shape except the
524 predictions must have one additional trailing dimension equal to the
525 number of classes(you want to predict).
526
527 Type of labels and predictions can be different.
528
529 Args:
530 labels: Tensor of shape (batch_size, ) containing integers
531 predictions: Tensor with the logits or probabilities for each example.
532 weights: Optional weighting of each example. Defaults to 1.
533
534 Returns:
535 The arguments, for easy chaining.
536 """
537 check_ops.assert_equal(
538 array_ops.shape(labels), array_ops.shape(predictions)[0],
539 message="First axis of labels and predictions is unequal")
540 predictions = math_ops.argmax(predictions, axis=-1)
541 labels = math_ops.cast(labels, dtypes.int64)
542 matches = math_ops.equal(labels, predictions)
543 matches = math_ops.cast(matches, self.dtype)
544 super(SparseAccuracy, self).call(matches, weights=weights)
545 if weights is None:
546 return labels, predictions
547 return labels, predictions, weights

Callers

nothing calls this directly

Calls 6

assert_equalMethod · 0.80
argmaxMethod · 0.80
equalMethod · 0.80
shapeMethod · 0.45
castMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected