aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Aurelien Geron <aurelien.geron@gmail.com>2018-08-04 19:42:08 +0100
committerGravatar Aurelien Geron <aurelien.geron@gmail.com>2018-08-04 19:42:08 +0100
commit923f1078e9798014b8e9d925b7d473f6e90e5745 (patch)
treef75de74029bd9bc3099eae8cb89a931ae551cc8b
parent3a41e5363530f058cb2b57cf0add09931ec788b2 (diff)
Fix the name property for the _UnreadVariable class in eager mode (fixes #21384)
-rw-r--r--tensorflow/python/ops/resource_variable_ops.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/tensorflow/python/ops/resource_variable_ops.py b/tensorflow/python/ops/resource_variable_ops.py
index 8b259b6b6b..664473003e 100644
--- a/tensorflow/python/ops/resource_variable_ops.py
+++ b/tensorflow/python/ops/resource_variable_ops.py
@@ -943,9 +943,10 @@ class ResourceVariable(variables.RefVariable):
if self.trainable:
tape.watch_variable(self)
return _UnreadVariable(
- self._handle, self.dtype, self._shape, self._in_graph_mode,
- self._handle_deleter if not self._in_graph_mode else None, op,
- self._unique_id)
+ handle=self._handle, dtype=self.dtype, shape=self._shape,
+ in_graph_mode=self._in_graph_mode,
+ deleter=self._handle_deleter if not self._in_graph_mode else None,
+ parent_op=op, parent_name=self._handle_name, unique_id=self._unique_id)
def assign(self, value, use_locking=None, name=None, read_value=True):
"""Assigns a new value to this variable.
@@ -1059,7 +1060,8 @@ class _UnreadVariable(ResourceVariable):
"""
def __init__(self, handle, dtype, # pylint: disable=super-init-not-called
- shape, in_graph_mode, deleter, parent_op, unique_id):
+ shape, in_graph_mode, deleter, parent_op, parent_name,
+ unique_id):
# We do not call super init on purpose.
self._trainable = False
self._save_slice_info = None
@@ -1069,7 +1071,7 @@ class _UnreadVariable(ResourceVariable):
self._shape = shape
self._initial_value = None
if isinstance(self._handle, ops.EagerTensor):
- self._handle_name = ""
+ self._handle_name = parent_name
else:
self._handle_name = self._handle.name
self._unique_id = unique_id
@@ -1085,10 +1087,6 @@ class _UnreadVariable(ResourceVariable):
self._graph_element = self.read_value()
self._handle_deleter = deleter
- @property
- def name(self):
- return self._parent_op.name
-
def value(self):
return self._read_variable_op()