【发布时间】:2020-05-21 11:45:22
【问题描述】:
我的 LSTM 层不断收到此错误。
ValueError: Error when checking input: expected lstm_input to have 3 dimensions, but got array with shape (None, 3)
为什么是形状 (None, 3),我该如何解决这个问题?另外,您如何判断数组的大小? 这是我的模型的代码:
class RNN():
def __init__(self, data, labels):
#get data for the model
self.SAMPLEAMOUT = 5
self.data = np.array(data)
self.labels = labels
print(self.data.shape)
#initialize model
self.model = Sequential()
self.model.add(LSTM(3, input_shape=self.data.shape))
self.model.add(Dense(9, activation='relu'))
self.model.add(Dense(1, activation='relu'))
self.model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
accuracy=['accuracy', 'loss'])
【问题讨论】:
-
lstm 接收这种格式的输入... (n_sample, time_seq, feature_dim)... 你的 time_seq 是多少?
-
什么是time_seq?抱歉,我对 LSTM 很陌生
标签: python-3.x keras lstm