![](/img/trans.png)
[英]Keras LSTM Layer ValueError: Dimensions must be equal, but are 17 and 2
[英]LSTM Keras ValueError
我在 LSTM 層中不斷收到此錯誤。
ValueError: Error when checking input: expected lstm_input to have 3 dimensions, but got array with shape (None, 3)
為什么是形狀(無,3),我該如何解決? 另外你怎么知道 arrays 的大小? 這是我的模型的代碼:
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'])
嘗試改變這個:
self.model.add(LSTM(3, input_shape=self.data.shape))
至:
self.model.add(LSTM(3, input_shape=self.data.shape[1:]))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.