occur error
HadXu opened this issue ยท 3 comments
HadXu commented
hello,I follow this repo,but occure error as follow,and my OS windows:
raise ValueError(err_msg)
elif isinstance(obj, Tensor) and allow_tensor:
# Actually obj is just the object it's referring to.
if obj.graph is not self:
raise ValueError("Tensor %s is not an element of this graph." % obj)
return obj
elif isinstance(obj, Operation) and allow_operation:
# Actually obj is just the object it's referring to.
if obj.graph is not self:
raise ValueError("Operation %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("fc1/Relu:0", shape=(?, 4096), dtype=float32) is not an element of this graph.
matsui528 commented
Hi,
I cannot reproduce your results, but this post might help. keras-team/keras#2397
HadXu commented
Thank you very much. This problem is solved as your suggestion.
fcagroupj commented
In keras, after loading model, call
graph = tf.get_default_graph()
set this as global.
When predicting with the model, use
global graph
with graph.as_default():
(... do inference here ...)