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

Method call

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

Accumulate accuracy statistics. For example, if labels is [1, 2, 3, 4] and predictions is [0, 2, 3, 4] then the accuracy is 3/4 or .75. If the weights were specified as [1, 1, 0, 0] then the accuracy would be 1/2 or .5. `labels` and `predictions` should have the same shape and typ

(self, labels, predictions, weights=None)

Source from the content-addressed store, hash-verified

374 super(Accuracy, self).__init__(name=name, dtype=dtype)
375
376 def call(self, labels, predictions, weights=None):
377 """Accumulate accuracy statistics.
378
379 For example, if labels is [1, 2, 3, 4] and predictions is [0, 2, 3, 4]
380 then the accuracy is 3/4 or .75. If the weights were specified as
381 [1, 1, 0, 0] then the accuracy would be 1/2 or .5.
382
383 `labels` and `predictions` should have the same shape and type.
384
385 Args:
386 labels: Tensor with the true labels for each example. One example
387 per element of the Tensor.
388 predictions: Tensor with the predicted label for each example.
389 weights: Optional weighting of each example. Defaults to 1.
390
391 Returns:
392 The arguments, for easy chaining.
393 """
394 check_ops.assert_equal(
395 array_ops.shape(labels), array_ops.shape(predictions),
396 message="Shapes of labels and predictions are unequal")
397 matches = math_ops.equal(labels, predictions)
398 matches = math_ops.cast(matches, self.dtype)
399 super(Accuracy, self).call(matches, weights=weights)
400 if weights is None:
401 return labels, predictions
402 return labels, predictions, weights
403
404
405class CategoricalAccuracy(Mean):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected