我想多類分類,這裏是我的訓練輸入的細節和輸出:ValueError異常:輸入0與層lstm_13不相容:預計NDIM = 3,發現NDIM = 4
train_input.shape= (1, 95000, 360) (95000 length input array with each element being an array of 360 length)
train_output.shape = (1, 95000, 22) (22 Classes are there)
model = Sequential()
model.add(LSTM(22, input_shape=(1, 95000,360)))
model.add(Dense(22, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print(model.summary())
model.fit(train_input, train_output, epochs=2, batch_size=500)
錯誤是:
ValueError: Input 0 is incompatible with layer lstm_13: expected ndim=3, found ndim=4 in line: model.add(LSTM(22, input_shape=(1, 95000,360)))
請幫我,我不能夠通過其他的答案來解決這個問題。
不,也給一些錯誤,如預期是:無,95000,360但發現1,95000,360 –
這是您的輸入數據形狀的問題。第一個維度應該是每個樣本。你的輸入應該是(n_samples,timesteps,n_features)。看看你的其他評論,95000是你的n_samples而不是你的時間步。如果你只有一個360時間步的功能,那麼你提出的是正確的格式。 – michetonu
好吧,我的輸入有360-360個塊(我想將其視爲特徵),那麼輸入的形狀和應該寫在裏面的內容應該是什麼 - > {model.add(LSTM(22,input_shape =(?)))} –