I have a code using low-level TF API. I want to add to it some code using Keras. I encountered a cryptic error with the simplest scenario: I have a Keras model which loads and predicts correctly. However, when I call tf.reset_default_graph before I get an error during load_model
tf.reset_default_graph()
model = load_model("model.h5")
I'm getting: ValueError: Tensor Tensor("Placeholder:0", shape=(40, 80), dtype=float32) is not an element of this graph.
The problem reproduces with the following minimal code:
import tensorflow as tf
from keras.models import load_model
model = load_model("model.h5")
model.summary()
# tf.reset_default_graph() OR
tf.keras.backend.clear_session()
model = load_model("model.h5")
model.summary()