ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
问答模型 `keras.layers.add`、`keras.layers.concatenate` ![](https://img.kancloud.cn/32/2b/322b3969cda38bb06eac667058e8be3a_480x545.png) **用API实现:** * 文本: ~~~ embedded_text = layers.Embedding(text_vocabulary_size, 64)(text_input) ↑将输入嵌入长度为64的向量 encoded_text = layers.LSTM(32)(embedded_text) ↑利用LSTM将向量编码为单个向量 question_input = Input(shape=(None,),dtype='int32',name='question') ~~~ * 问题: ~~~ embedded_question = layers.Embedding( question_vocabulary_size, 32)(question_input) encoded_question = layers.LSTM(16)(embedded_question) ~~~ * concatenate: ~~~ concatenated = layers.concatenate([encoded_text, encoded_question],axis=-1) ~~~ * 回答: ~~~ answer = layers.Dense(answer_vocabulary_size, activation='softmax')(concatenated) ~~~