首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输入0与层lstm_16不兼容:预期的ndim=3,找到的ndim=2?

输入0与层lstm_16不兼容:预期的ndim=3,找到的ndim=2?
EN

Stack Overflow用户
提问于 2019-11-07 11:41:37
回答 1查看 139关注 0票数 0

我得到了错误Input 0 is incompatible with layer lstm_16: expected ndim=3, found ndim=2,代码如下:

代码语言:javascript
复制
#Step 6: Initialize the RNN
regressor = Sequential()

#Step 7: Adding the LSTM layers and some Dropout regularization

#Dropout regularization: drops out unnecessary data, so we are not shifting huge amounts of data through the network

#Adding the first LSTM layer and some Dropout regularization
#units - dimensionality in output space
regressor.add(LSTM(units = 50, return_sequences = True, input_shape = (X_train.shape[1], 1)))

#Adding the second LSTM layer and some Dropout regulariation
regressor.add(LSTM(units = 25, return_sequences = True))
regressor.add(Dropout(0.2))

#Adding a third LSTM layer and some Dropout regularization
regressor.add(LSTM(units = 12, return_sequences = True))
regressor.add(Dropout(0.2))

#Adding a fourth LSTM layer and some Dropout regularization
regressor.add(LSTM(units = 6))
regressor.add(Dropout(0.2))

#Step 8: Adding the output layer
regressor.add(Dense(units = 1))

X_train的尺寸为(114, 1, 216) (在I computer X_train.shape时生成)。为什么我会得到这个错误?

EN

回答 1

Stack Overflow用户

发布于 2020-04-27 01:28:49

在这里,您将在第一个LSTM层的input_shape中传递两个值。

(samples, time_steps, nfeatures)LSTM需要和输入的形状,您的图层输入必须具有此形状。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58741673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档