Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated tf.contrib.metrics.streaming_accuracy with tf.metrics.accuracy #18154

Merged
merged 4 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions tensorflow/contrib/training/python/training/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@

# Choose the metrics to compute:
names_to_values, names_to_updates = tf.contrib.metrics.aggregate_metric_map({
"accuracy": tf.contrib.metrics.streaming_accuracy(predictions, labels),
"mse": tf.contrib.metrics.streaming_mean_squared_error(
predictions, labels),
"accuracy": tf.metrics.accuracy(labels, predictions),
"mse": tf.metrics.mean_squared_error(labels, predictions),
})

# Define the summaries to write:
Expand Down Expand Up @@ -81,9 +80,8 @@

# Choose the metrics to compute:
names_to_values, names_to_updates = tf.contrib.metrics.aggregate_metric_map({
"accuracy": tf.contrib.metrics.streaming_accuracy(predictions, labels),
"mse": tf.contrib.metrics.streaming_mean_squared_error(
predictions, labels),
"accuracy": tf.metrics.accuracy(labels, predictions),
"mse": tf.metrics.mean_squared_error(labels, predictions),
})

# Define the summaries to write:
Expand Down
16 changes: 9 additions & 7 deletions tensorflow/contrib/training/python/training/evaluation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from tensorflow.contrib.framework.python.ops import variables
from tensorflow.contrib.layers.python.layers import layers
from tensorflow.contrib.losses.python.losses import loss_ops
from tensorflow.contrib.metrics.python.ops import metric_ops
from tensorflow.contrib.training.python.training import evaluation
from tensorflow.contrib.training.python.training import training
from tensorflow.core.protobuf import config_pb2
Expand All @@ -38,6 +37,7 @@
from tensorflow.python.framework import random_seed
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import metrics
from tensorflow.python.ops import state_ops
from tensorflow.python.ops import variables as variables_lib
from tensorflow.python.platform import gfile
Expand Down Expand Up @@ -196,7 +196,8 @@ def testEvaluatePerfectModel(self):
logits = logistic_classifier(inputs)
predictions = math_ops.round(logits)

accuracy, update_op = metric_ops.streaming_accuracy(predictions, labels)
accuracy, update_op = metrics.accuracy(
predictions=predictions, labels=labels)

checkpoint_path = evaluation.wait_for_new_checkpoint(checkpoint_dir)

Expand Down Expand Up @@ -311,7 +312,8 @@ def testEvaluatePerfectModel(self):
logits = logistic_classifier(inputs)
predictions = math_ops.round(logits)

accuracy, update_op = metric_ops.streaming_accuracy(predictions, labels)
accuracy, update_op = metrics.accuracy(
predictions=predictions, labels=labels)

final_values = evaluation.evaluate_repeatedly(
checkpoint_dir=checkpoint_dir,
Expand Down Expand Up @@ -365,7 +367,8 @@ def testEvaluationLoopTimeoutWithTimeoutFn(self):
logits = logistic_classifier(inputs)
predictions = math_ops.round(logits)

accuracy, update_op = metric_ops.streaming_accuracy(predictions, labels)
accuracy, update_op = metrics.accuracy(
predictions=predictions, labels=labels)

timeout_fn_calls = [0]
def timeout_fn():
Expand Down Expand Up @@ -417,9 +420,8 @@ def testEvaluateWithEvalFeedDict(self):
self.assertEqual(final_values['my_var'], expected_value)

def _create_names_to_metrics(self, predictions, labels):
accuracy0, update_op0 = metric_ops.streaming_accuracy(predictions, labels)
accuracy1, update_op1 = metric_ops.streaming_accuracy(
predictions + 1, labels)
accuracy0, update_op0 = metrics.accuracy(labels, predictions)
accuracy1, update_op1 = metrics.accuracy(labels, predictions + 1)

names_to_values = {'Accuracy': accuracy0, 'Another_accuracy': accuracy1}
names_to_updates = {'Accuracy': update_op0, 'Another_accuracy': update_op1}
Expand Down