aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-03-21 15:19:43 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-03-21 22:07:14 -0700
commitcb8070b4b50b21297ddb00c250cf1da31613aea9 (patch)
tree553fd0a9e4831cf3f56fa30b2e077a4802345c8c
parent6047c6977dbc30f018b8b3ea0486ca907901dabb (diff)
When variable op scope fails, give some indication about where the variable was originally defined.
Change: 117766780
-rw-r--r--tensorflow/python/ops/variable_scope.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tensorflow/python/ops/variable_scope.py b/tensorflow/python/ops/variable_scope.py
index 219b72b2bc..e39597de56 100644
--- a/tensorflow/python/ops/variable_scope.py
+++ b/tensorflow/python/ops/variable_scope.py
@@ -20,6 +20,7 @@ from __future__ import division
from __future__ import print_function
import contextlib
+import traceback
import six
@@ -108,8 +109,13 @@ class _VariableStore(object):
if name in self._vars:
# Here we handle the case when returning an existing variable.
if should_check and not reuse:
+ tb = self._vars[name].op.traceback[::-1]
+ # Throw away internal tf entries and only take a few lines.
+ tb = [x for x in tb if "tensorflow/python" not in x[0]][:3]
raise ValueError("Variable %s already exists, disallowed."
- " Did you mean to set reuse=True in VarScope?" % name)
+ " Did you mean to set reuse=True in VarScope? "
+ "Originally defined at:\n\n%s" % (
+ name, "".join(traceback.format_list(tb))))
found_var = self._vars[name]
if not shape.is_compatible_with(found_var.get_shape()):
raise ValueError("Trying to share variable %s, but specified shape %s"