我正在建立一个网站,有时它称为keras神经网络。所以我有一个看起来像这样的函数:
def network(campaign):
from keras.models import load_model
model = load_model("sunshade/neural_network/model.h5") #the line that fail the second time i call it
#loading some data
label = model.predict(images, batch_size = 128, verbose = 1)
#some unrelated code...
Run Code Online (Sandbox Code Playgroud)
当我第一次执行此代码时,它运行良好,但是当我尝试第二次运行时,它因以下错误而失败:
Exception in thread Thread-31:
Traceback (most recent call last):
File "/usr/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 930, in _run
allow_operation=False)
File "/usr/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py", line 2414, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/usr/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py", line 2493, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj) …Run Code Online (Sandbox Code Playgroud)