Describe the bug
AttributeError: module 'tensorflow.python.keras.engine.base_layer_utils' has no attribute 'unique_layer_name'.
To Reproduce
In Part 13b - Secure Classification with Syft Keras and TFE - Secure Model Serving, I encounter the next problem when execeute "model.share(alice, bob, carol)":
AttributeError Traceback (most recent call last)
----> 1 model.share(alice, bob, carol)
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\frameworks\keras\model\sequential.py in share(model, target_graph, *workers)
38
39 with target_graph.as_default():
---> 40 tfe_model, batch_input_shape = _rebuild_tfe_model(model, stored_keras_weights)
41
42 # Set up a new tfe.serving.QueueServer for the shared TFE model
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\frameworks\keras\model\sequential.py in _rebuild_tfe_model(keras_model, stored_keras_weights)
112 """
113
--> 114 tfe_model = tfe.keras.Sequential()
115
116 for keras_layer in keras_model.layers:
D:\ProgramData\Anaconda3\lib\site-packages\tf_encrypted-0.5.4-py3.6.egg\tf_encrypted\keras\engine\sequential.py in __init__(self, layers, name)
10 """
11 def __init__(self, layers=None, name=None):
---> 12 super(Sequential, self).__init__(name=name)
13
14 self._layers = []
D:\ProgramData\Anaconda3\lib\site-packages\tf_encrypted-0.5.4-py3.6.egg\tf_encrypted\keras\engine\base_layer.py in __init__(self, trainable, name, **kwargs)
51
52 self.trainable = trainable
---> 53 self._init_set_name(name)
54 self.built = False
55
D:\ProgramData\Anaconda3\lib\site-packages\tf_encrypted-0.5.4-py3.6.egg\tf_encrypted\keras\engine\base_layer.py in _init_set_name(self, name, zero_based)
108 def _init_set_name(self, name, zero_based=True):
109 if not name:
--> 110 self._name = base_layer_utils.unique_layer_name(
111 generic_utils.to_snake_case(self.__class__.__name__),
112 zero_based=zero_based)
AttributeError: module 'tensorflow.python.keras.engine.base_layer_utils' has no attribute 'unique_layer_name'
Desktop (please complete the following information):
@AndyClouder has similar issues in #2234
The best way to solve this at the moment would be to install your tf-encrypted dependency from source. We will do a release of tf-encrypted on Monday that fixes this issue in the pip package.
Instructions can be found here
Instructions can be found here
I install the tf-encrypted dependency from source as you suggest and get the following error:
FileNotFoundError Traceback (most recent call last)
----> 1 model.share(alice, bob, carol)
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\frameworks\keras\model\sequential.py in share(model, target_graph, *workers)
55 # Tell the TFE workers to launch TF servers
56 for player_name, worker in player_to_worker_mapping.items():
---> 57 worker.start(player_name, *workers)
58
59 # Push and initialize shared model on servers
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\workers\tfe.py in start(self, player_name, *workers)
23
24 config, _ = self.config_from_workers(workers)
---> 25 config.save(config_filename)
26
27 if self._auto_managed:
c:\users\administrator\tf-encrypted\tf_encrypted\config.py in save(self, filename)
232 :param str filename: Name of file to save to.
233 """
--> 234 with open(filename, 'w') as f:
235 json.dump(self.hostmap, f)
236
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tfe.config'
Instructions can be found here
And I try changing the config_filename = "/tmp/tfe.config" in C:\Users\Administrator\Desktop\covert security\codes\PySyft-dev\PySyft-dev\syft\workers\tfe.py to config_filename = "/tfe.config", and get the following error:
ValueError Traceback (most recent call last)
----> 1 model.share(alice, bob, carol)
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\frameworks\keras\model\sequential.py in share(model, target_graph, *workers)
31
32 # Handle input combinations to configure TFE
---> 33 player_to_worker_mapping = _configure_tfe(workers)
34
35 if target_graph is None:
D:\ProgramData\Anaconda3\lib\site-packages\syft-0.1.15a1-py3.6.egg\syft\frameworks\keras\model\sequential.py in _configure_tfe(workers)
99 config.get_player("server0"), config.get_player("server1"), config.get_player("server2")
100 )
--> 101 tfe.set_protocol(prot)
102
103 return player_to_worker_mapping
c:\users\administrator\tf-encrypted\tf_encrypted__init__.py in set_protocol(prot)
40 # add global names according to new protocol
41 if prot is not None:
---> 42 methods = inspect.getmembers(prot, predicate=inspect.ismethod)
43 public_methods = [
44 method for method in methods if not method[0].startswith('_')]
D:\ProgramData\Anaconda3\lib\inspect.py in getmembers(object, predicate)
340 # looking in the __dict__.
341 try:
--> 342 value = getattr(object, key)
343 # handle the duplicate key
344 if key in processed:
c:\users\administrator\tf-encrypted\tf_encrypted\protocol\pond\pond.py in initializer(self)
599 @property
600 def initializer(self) -> tf.Operation:
--> 601 return tf.group(*_initializers)
602
603 def clear_initializers(self) -> None:
D:\ProgramData\Anaconda3\lib\site-packages\tensorflow-1.14.0rc0-py3.6-win-amd64.egg\tensorflow\python\ops\control_flow_ops.py in group(inputs, *kwargs)
3621 if kwargs:
3622 raise ValueError("Unknown keyword arguments: " + ", ".join(kwargs.keys()))
-> 3623 with ops.name_scope(name, "group_deps", inputs) as name:
3624 # Grouping no inputs means do nothing
3625 if not inputs:
D:\ProgramData\Anaconda3\lib\site-packages\tensorflow-1.14.0rc0-py3.6-win-amd64.egg\tensorflow\python\framework\ops.py in __enter__(self)
6506 if self._values is None:
6507 self._values = []
-> 6508 g = _get_graph_from_inputs(self._values)
6509 self._g_manager = g.as_default()
6510 self._g_manager.__enter__()
D:\ProgramData\Anaconda3\lib\site-packages\tensorflow-1.14.0rc0-py3.6-win-amd64.egg\tensorflow\python\framework\ops.py in _get_graph_from_inputs(op_input_list, graph)
6133 graph = graph_element.graph
6134 elif original_graph_element is not None:
-> 6135 _assert_same_graph(original_graph_element, graph_element)
6136 elif graph_element.graph is not graph:
6137 raise ValueError("%s is not from the passed-in graph." % graph_element)
D:\ProgramData\Anaconda3\lib\site-packages\tensorflow-1.14.0rc0-py3.6-win-amd64.egg\tensorflow\python\framework\ops.py in _assert_same_graph(original_item, item)
6069 if original_item.graph is not item.graph:
6070 raise ValueError("%s must be from the same graph as %s." %
-> 6071 (item, original_item))
6072
6073
ValueError: name: "group_deps"
op: "NoOp"
input: "^group_deps/NoOp"
input: "^group_deps/NoOp_1"
must be from the same graph as name: "group_deps"
op: "NoOp"
input: "^group_deps/NoOp"
input: "^group_deps/NoOp_1"
.
We will do a release of tf-encrypted on Monday that fixes this issue in the pip package.
I just pushed tf-encrypted version 0.5.5 to PyPI, and the original AttributeError bug in this issue is fixed when using TF 1.14.0-rc0. For anyone reading this, please ensure you've either upgraded tf-encrypted to 0.5.5 or downgraded your version of TensorFlow to 1.13.1.
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tfe.config'
This one should be fixed by #2254, which is now in dev. Please open up a new bug report if this continues to be a problem there.
ValueError: name: "group_deps" ...
This one is more interesting -- @mortendahl any idea what could be going on here? If this is more than a quick fix, I suggest moving that discussion to a new issue since this one should be resolved now.
We will do a release of tf-encrypted on Monday that fixes this issue in the pip package.
I just pushed tf-encrypted version 0.5.5 to PyPI, and the original AttributeError bug in this issue is fixed when using TF 1.14.0-rc0. For anyone reading this, please ensure you've either upgraded tf-encrypted to 0.5.5 or downgraded your version of TensorFlow to 1.13.1.
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tfe.config'
This one should be fixed by #2254, which is now in
dev. Please open up a new bug report if this continues to be a problem there.ValueError: name: "group_deps" ...
This one is more interesting -- @mortendahl any idea what could be going on here? If this is more than a quick fix, I suggest moving that discussion to a new issue since this one should be resolved now.
Thank you very much. When I reinstall the tf-encrypted to version 0.5.5 and reinstall pysft, the error disappear. But there exist another problem. And I start a new issue to discuss it.
Thank you again for your quick reply.
@jvmancuso is this fixed now?
Yup!