Accuracy
Inherits From: Mean
Defined in tensorflow/contrib/eager/python/metrics_impl.py.
Calculates how often predictions matches labels.
namevariables__init____init__(
name=None,
dtype=tf.double
)
Initialize self. See help(type(self)) for accurate signature.
__call____call__(
*args,
**kwargs
)
Returns op to execute to update this metric for these inputs.
Returns None if eager execution is enabled. Returns a graph-mode function if graph execution is enabled.
*args: * **kwargs: A mini-batch of inputs to the Metric, passed on to call().add_variableadd_variable(
name,
shape=None,
dtype=None,
initializer=None
)
Only for use by descendants of Metric.
aggregateaggregate(metrics)
Adds in the state from a list of metrics.
Default implementation sums all the metric variables.
metrics: A list of metrics with the same type as self.ValueError: If metrics contains invalid data.buildbuild(
*args,
**kwargs
)
Method to create variables.
Called by __call__() before call() for the first time.
*args: * **kwargs: The arguments to the first invocation of __call__(). build() may use the shape and/or dtype of these arguments when deciding how to create variables.callcall(
labels,
predictions,
weights=None
)
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 type.
labels: Tensor with the true labels for each example. One example per element of the Tensor.predictions: Tensor with the predicted label for each example.weights: Optional weighting of each example. Defaults to 1.The arguments, for easy chaining.
init_variablesinit_variables()
Initializes this Metric's variables.
Should be called after variables are created in the first execution of __call__(). If using graph execution, the return value should be run() in a session before running the op returned by __call__(). (See example above.)
If using graph execution, this returns an op to perform the initialization. Under eager execution, the variables are reset to their initial values as a side effect and this function returns None.
resultresult()
Computes and returns a final value for the metric.
valuevalue()
In graph mode returns the result Tensor while in eager the callable.
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/eager/metrics/Accuracy