【发布时间】:2017-10-18 11:11:11
【问题描述】:
我有 2 个不同的神经网络模型,使用 TFLearn 训练和保存。当我运行每个脚本时,保存的模型会正确加载。我需要一个系统,在第一个模型的输出之后应该调用第二个模型。 但是当我在加载第一个模型后尝试加载第二个模型时,它给了我以下错误:
NotFoundError(请参阅上面的回溯):检查点中未找到密钥 val_loss_2 [[节点:save_6/RestoreV2_42 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save_6/Const_0_0, save_6/RestoreV2_42/tensor_names, save_6/恢复V2_42/shape_and_slices)]]
如果我注释掉第一个模型的加载,或者如果我分别运行 2 个脚本,则第二个模型会正确加载。知道为什么会发生此错误吗?
代码结构类似于..
from second_model_file import check_second_model
def run_first_model(input):
features = convert_to_features(input)
model = tflearn.DNN(get_model())
model.load("model1_path/model1") # relative path
pred = model.predict(features)
...
if pred == certain_value:
check_second_model()
second_model_file.py 类似:
def check_second_model():
input_var = get_input_var()
model2 = tflearn.DNN(regression_model())
model2.load("model2_path/model2") # relative path
pred = model2.predict(input_var)
#other stuff ......
模型已保存在不同的文件夹中,因此每个都有自己的checkpoint 文件
【问题讨论】:
标签: python neural-network tflearn