【发布时间】:2019-05-25 19:42:05
【问题描述】:
我已经训练了一个用于肺炎检测的 CNN。我已将训练模型的权重保存在同一路径中。现在我重新启动程序后无法使用保存的模型来预测数据。
我尝试执行负责预测的特定代码行,但随后出现导入错误,从中我可以理解我必须重新运行整个程序,这又需要时间。这是实际的预测代码。
res = classifier.predict(test_image)
if res[0][0] == 1:
prediction = 'pnemonia'
elif res[0][0] == 0:
prediction = 'normal'
print(prediction)
实际结果一定是预测。相反,我得到了
Using TensorFlow backend.
Traceback (most recent call last):
File "<input>", line 5, in <module>
NameError: name 'np' is not defined
【问题讨论】:
标签: python keras model load predict