python - 输出一个 3 形状的 LSTM
问题描述
我试图了解 LSTM 的基础知识并构建了这个模型:
self.model = Sequential()
self.model.add(LSTM(self.config.layers[0],
input_shape=(None, channel.X_train.shape[2]),
return_sequences=True))
self.model.add(Dropout(self.config.dropout))
self.model.add(LSTM(
self.config.layers[1],
return_sequences=True))
self.model.add(Dropout(self.config.dropout))
self.model.add(Dense(
self.config.n_predictions))
self.model.add(Activation('linear'))
输入形状是 (2000, 200, 10),我需要一个相同形状的输出。我尝试过这种方式,但我得到了错误:
ValueError: Input 0 is incompatible with layer lstm_2: expected ndim=3, found ndim=2
如果我将第二层的 return_sequence 参数设置为False,它会起作用,但我会得到形状 (X, Y) 的输出,这不是我想要的。
解决方案
推荐阅读
- c# - 如何使用 AES 加密文本文件以外的文件?PDF、Word 等
- api - REST 基础架构设计所需的建议
- grafana - Grafana,涌入数据库
- database - 从图片中绘制 R-tree
- android - 使用颤振飞镖和 api 的测验应用程序,找不到正确的提供者
- flask - 带有自动提交按钮的烧瓶中的相互依赖下拉列表
- c# - 如何使用rendertreebuilder动态构建父子组件?
- javascript - JS Promise 和 Pipe 的问题
- python - 如何将 .properties 文件复制到 jenkins 工作区,以便它可以被 python 脚本使用
- parallel-processing - julia @distributed 没有扩大规模