目录
如果有一个经过训练的模型,接下来就可以对其进行预测:
sample_1="""
I hate that the dismal weather had me down for so long,when will it break! Ugh,when does happiness return? The sun is blinding and the puffy clouds are too thin. I can't wait for the weekend.
"""
from keras.api.models import model_from_json
with open("simplernn_model1.json","r") as json_file:
json_string=json_file.read()
model=model_from_json(json_string)
model.load_weights('simplernn_weights1.h5')
vec_list=tokenize_and_vectorize([(1,sample_1)])
test_vec_list=pad_turnc(vec_list,maxlen)
test_vec=np.reshape(test_vec_list,(len(test_vec_list),maxlen,embedding_dims))
print(model.predict_classes(test_vec))
结果是负向的。
我们又有了一个可以添加到流水线中的工具,可以对可能的回复以及用户可能输入的问题或搜索进行分类。选择循环神经网络的原因之一是:与前馈网络或卷积神经网络相比,循环神经网络训练和传递新样本的成本相对较高。
对于使用RNN