Convert tensorflow tensor to Keras tensor
See original GitHub issueI have a trained tensorflow model that I’ve loaded using the checkpoint and meta files. The model loads properly. But now I’d like to work with the same model using Keras, instead of direct tensorflow.
I got the input and output tensor of the loaded model:
images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0")
Now I want to create a Keras model with these, so I tried this:
model = Model(images_placeholder,embeddings)
This however, gives me this error:
TypeError: Input tensors to a Model must be Keras tensors. Found: Tensor("input:0", shape=(?, 160, 160, 3), dtype=float32) (missing Keras metadata).
Any ideas on how to fix this? I also don’t know the architecture of this model, so I wanted to do model.summary() after the keras model is loaded. I thought Keras worked seamlessly with Tensorflow and Theano graphs…
Issue Analytics
- State:
- Created 7 years ago
- Reactions:10
- Comments:19 (7 by maintainers)
Top Related StackOverflow Question
Make your own layer: https://keras.io/layers/writing-your-own-keras-layers/
@fornaciari I raised a question at https://stackoverflow.com/questions/55354612/how-to-turn-a-tf-tensor-to-some-form-that-keras-can-fit, and someone metioned your custom layer way. You can see my code shown below, I tried as you explained to me just now, and still got some error:
_AttributeError: ‘NoneType’ object has no attribute 'inbound_nodes’