diff --git a/tensorflow/contrib/layers/python/layers/optimizers.py b/tensorflow/contrib/layers/python/layers/optimizers.py index 8c06202f47b..6cb7e91b73f 100644 --- a/tensorflow/contrib/layers/python/layers/optimizers.py +++ b/tensorflow/contrib/layers/python/layers/optimizers.py @@ -258,10 +258,11 @@ def optimize_loss(loss, grad_values = gradient if grad_values is not None: + var_name = variable.name.replace(":", "_") if "gradients" in summaries: - summary.histogram("gradients/" + variable.name, grad_values) + summary.histogram("gradients/%s" % var_name, grad_values) if "gradient_norm" in summaries: - summary.scalar("gradient_norm/" + variable.name, + summary.scalar("gradient_norm/%s" % var_name, clip_ops.global_norm([grad_values])) if clip_gradients is not None and "gradient_norm" in summaries: diff --git a/tensorflow/python/summary/summary.py b/tensorflow/python/summary/summary.py index a6b348cc991..b5db6b802fa 100644 --- a/tensorflow/python/summary/summary.py +++ b/tensorflow/python/summary/summary.py @@ -35,8 +35,6 @@ from __future__ import print_function import re as _re -import six - from google.protobuf import json_format as _json_format from tensorflow.core.framework import summary_pb2 as _summary_pb2 from tensorflow.python.framework import dtypes as _dtypes @@ -47,8 +45,8 @@ from tensorflow.python.ops import gen_logging_ops as _gen_logging_ops from tensorflow.python.ops.summary_ops import tensor_summary # pylint: enable=unused-import from tensorflow.python.platform import tf_logging as _logging -from tensorflow.python.util.all_util import remove_undocumented from tensorflow.python.util import compat as _compat +from tensorflow.python.util.all_util import remove_undocumented def _collect(val, collections, default_collections): @@ -60,6 +58,7 @@ def _collect(val, collections, default_collections): _INVALID_TAG_CHARACTERS = _re.compile(r'[^-/\w\.]') + def _clean_tag(name): # In the past, the first argument to summary ops was a tag, which allowed # arbitrary characters. Now we are changing the first argument to be the node