Hello,
I’m attracted by the possibility to include Keras models as TensorNode in nengo_dl, but I am stacked with an error in all my attempts.
At this point I tested the example given in nengo_dl package (tensorflow-models.ipynb), and I got exactly the same error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1092, in _run
subfeed, allow_tensor=True, allow_operation=False)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3478, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3557, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("SimTensorNodeBuilder_1/Placeholder:0", shape=(784, 128), dtype=float32) is not an element of this graph.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tensorflow-models.py", line 87, in <module>
with nengo_dl.Simulator(net, minibatch_size=minibatch_size) as sim:
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/simulator.py", line 221, in __init__
self.reset(seed=seed)
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/simulator.py", line 252, in reset
self.tensor_graph.build_post(self.sess, self.rng)
File "/usr/local/lib/python3.6/dist-packages/nengo/utils/magic.py", line 181, in __call__
self.__wrapped__, self.instance, args, kwargs)
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/tensor_graph.py", line 39, in with_self
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/tensor_graph.py", line 725, in build_post
self.op_builder.post_build(sess, rng)
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/builder.py", line 135, in post_build
self.op_builds[ops].build_post(ops, self.signals, sess, rng)
File "/usr/local/lib/python3.6/dist-packages/nengo_dl/tensor_node.py", line 243, in build_post
self.func.post_build(sess, rng)
File "tensorflow-models.py", line 63, in post_build
self.model.load_weights(model_weights)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/network.py", line 1516, in load_weights
saving.load_weights_from_hdf5_group(f, self.layers)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/saving.py", line 820, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py", line 2880, in batch_set_value
get_session().run(assign_ops, feed_dict=feed_dict)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1095, in _run
'Cannot interpret feed_dict key as Tensor: ' + e.args[0])
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("SimTensorNodeBuilder_1/Placeholder:0", shape=(784, 128), dtype=float32) is not an element of this graph.
I’m using the following versions:
- nengo_dl 2.1.1
- Keras 2.2.4
- tensorflow 1.13.1
I would greatly appreciate your help
Alessio