I've made simple prediction model with keras and bag of words based on the code which I found in the tutorials. Loading dataset and training finished without problem and accuracy is around 88%.
Dataset has two columns text and tag (i.e. "some text, a"). How can I test trained model with some other data which is not in dataset like model.predict(some text)?
以下是示例数据集: 泰克斯特,塔格 斯科托,n Trg Vinodolskog zakona 5号,a 我希望保存模型,这样就不必每次运行脚本时都训练它。是正确的方式放在剧本的结尾“模型.保存('my_model.h5')”? 如何加载模型并使用数据集中没有的数据进行预测?在
^{pr2}$
训练完模型后,可以使用
model.save_weights(path)
将权重保存到磁盘。在然后可以使用
model.load_weights(path)
将权重加载到同一架构的模型中。在如果您还想保存模型体系结构,可以使用更通用的
model.save(path)
,它将保存然后可以使用加载模型
在您恢复了模型及其权重之后,您可以
^{pr2}$evaluate
该模型来确定其准确性,或者使用predictions
对新数据执行predictions
是的,根据Keras Documentation FAQ page。您只需键入:
model.save(filepath)
。 如果您想加载已经存在的模型,请使用:keras.models.load_model(filepath)
。在相关问题 更多 >
编程相关推荐