aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Priya Gupta <priyag@google.com>2018-04-04 15:15:32 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-04-04 15:20:23 -0700
commit1093a54cb79be1dd606eee9ff27b718006ba9d63 (patch)
tree9b4d31a4a7573f7d9c6b6315b85c7ff6f9047f03
parentbf8ad8277258bdf352ddd1df5200e61ba625f7a2 (diff)
Iterate over a copy of dictionary keys when closing variable subscopes. Otherwise, we run into a "dictionary changed size during iteration" once in a while, as we are modifying the values in the dictionary during the iteration.
PiperOrigin-RevId: 191655599
-rw-r--r--tensorflow/python/ops/variable_scope.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tensorflow/python/ops/variable_scope.py b/tensorflow/python/ops/variable_scope.py
index c35735ca65..e33085ba62 100644
--- a/tensorflow/python/ops/variable_scope.py
+++ b/tensorflow/python/ops/variable_scope.py
@@ -1164,7 +1164,7 @@ class _VariableScopeStore(threading.local):
self.variable_scopes_count[scope_name] = 1
def close_variable_subscopes(self, scope_name):
- for k in self.variable_scopes_count:
+ for k in list(self.variable_scopes_count.keys()):
if not scope_name or k.startswith(scope_name + "/"):
self.variable_scopes_count[k] = 0