python - 如何使用双向 lstm 预测摘要问题中的新输入
问题描述
我使用双向 lstm 创建了一个汇总模型,该模型在训练中的准确率约为 90%。但是对于测试传统的 model.predict 方法是行不通的。有没有其他方法可以预测新输入的摘要?
我的模型如下
encoder_inputs = Input(shape=(MAX_LEN,))
encoder_embedding = encoder_embedding_layer(encoder_inputs)
encoder_LSTM = LSTM(HIDDEN_UNITS, return_state=True)
encoder_LSTM_R = LSTM(HIDDEN_UNITS, return_state=True, go_backwards=True)
encoder_outputs_R, state_h_R, state_c_R = encoder_LSTM_R(encoder_embedding)
encoder_outputs, state_h, state_c = encoder_LSTM(encoder_embedding)
final_h = Add()([state_h, state_h_R])
final_c = Add()([state_c, state_c_R])
encoder_states = [final_h, final_c]
decoder_inputs = Input(shape=(MAX_LEN,))
decoder_embedding = decoder_embedding_layer(decoder_inputs)
decoder_LSTM = LSTM(HIDDEN_UNITS, return_sequences=True, return_state=True)
decoder_outputs, _, _ = decoder_LSTM(decoder_embedding, initial_state=encoder_states)
decoder_dense = Dense(VOCAB_SIZE, activation='softmax')
decoder_outputs = decoder_dense(decoder_outputs)
model_2= Model(inputs=[encoder_inputs,decoder_inputs], outputs=decoder_outputs)
解决方案
推荐阅读
- embedded - 如何在 keil 中为 stm32 添加库?
- swift - 标签文本居中并根据下面标签中的文本行数移动
- python - 将 QToolBar 放入 QWidget 而不是 QMainWindow
- xslt-1.0 - XSLT 日期格式转换,例如:2018 年 8 月 23 日至 23/08/2018
- javascript - 扩展状态反应
- javascript - html2canvas 未捕获(承诺)未定义
- docker - 当 docker-compose 有端口映射时,Traefik 无法到达后端
- python - 尝试将 python 脚本放在一起,在每周开始时通过电子邮件向我发送一周的事件
- angular - 如何使用angular2在正文上附加内容
- ruby - 必发 API 输出时区有时会关闭