【Python机器学习】循环神经网络(RNN)——对RNN进行预测

目录

有状态性

双向RNN

编码向量


如果有一个经过训练的模型,接下来就可以对其进行预测:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值