0
我正在嘗試使用LSTM來訓練一個簡單的多對一RNN分類器。我的時間步長爲100個數據點,具有7個特徵,總共有192382個樣本。這是我的型號:多對一的LSTM,Keras上的softmax尺寸錯誤
model = Sequential()
model.add(LSTM(50,input_shape = (100,7),name = 'LSTM',return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(3, activation='softmax',name = 'softmax_layer'))
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'],name='softmax')
model.fit(datax,datay,epochs=25,batch_size=128)
model.summary()
該模型編譯罰款沒有錯誤,但我不能適應模型。這是它返回的錯誤:
ValueError: Error when checking target: expected softmax_layer to have shape (None, 3) but got array with shape (192282, 100)
有沒有人有一個想法,爲什麼softmax圖層返回一個(192282,100)矩陣? LSTM層中的return_sequence = False是否應該只給每個時間步輸出一個輸出?
假設你正在分類至3班,你傳遞DATAY錯誤的值 – ilan