From a94863a3d3a7371d589b35e071dabeadaf6cea24 Mon Sep 17 00:00:00 2001 From: Marcel Rieger Date: Fri, 23 Dec 2016 11:36:29 +0100 Subject: [PATCH] Simplify default key for root tensors. --- tfdeploy.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tfdeploy.py b/tfdeploy.py index 566c086..21a3244 100644 --- a/tfdeploy.py +++ b/tfdeploy.py @@ -153,9 +153,10 @@ def add(self, tensor, tf_sess=None, key=None, **kwargs): tensor = Tensor(tensor, tf_sess, **kwargs) if key is None: - key = len(self.roots) - while key in self.roots: - key += 1 + if len(self.roots) == 0: + key = 0 + else: + key = max(self.roots.keys()) + 1 self.roots[key] = tensor